Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to login to a database by running an SQL file from a unix script without supplying username and password (as root) this possible?

Database is oracle

share|improve this question
You might want to mention the database, what are the database accounts and permissions, etc. – Keith Mar 1 '11 at 6:03
database is oracle – sam Mar 1 '11 at 6:15

You can define your database users as being OS Authenticated. Tim Hall's Oracle_Base site has a good primer on how to do this. You don't need to allow folks to log in with SYSDBA privileges, a recipe for disaster.

share|improve this answer
+1 thx for introducing "OS Authentication". Did not know about it. Will have plenty of opportunity to use it. – Alain Pannetier Mar 1 '11 at 18:28
Oracle also has the ability to authenticate to LDAP servers, e.g., Active Directory for domain authentication. You need a separate piece for that feature - added cost option :-/ – DCookie Mar 1 '11 at 18:35
Indeed I've implemented OID in the past. Just forgot about it... :-( I'll dust off this domain tomorrow. – Alain Pannetier Mar 1 '11 at 21:16

If your user is in the oracle group, he can connect as SYSDBA.

Example on a Unix env:

$ sqlplus /nolog

SQL*Plus: Release...

SP2-0640: Not connected
sql> connect / as sysdba

SQL> select * from scott.employees ;

That might be something of an overkill for a batch (besides the fact that you have all privileges to screw up your db).

However AFAIK, that's the only option.

UPDATE Given DCookie's answer, this is not the only way. And as I already mentioned and underlined by DCookie this is a very risky path.

share|improve this answer
It's not the only option, and it's a pretty dangerous one as well. A SYSDBA user can do ANYTHING to the database. Plus, you need to set up the logged in user to be able to log in with these privileges anyway. – DCookie Mar 1 '11 at 17:00
@Alain Pannetier Hi, I used oracle vm on my gentoo linux. I kad same problem, my oracle user is in oracle group but I can not connect as sysdba. DB is 12c+oracle linux. Any comment maybe? My ORACLE_SID is set to orcl. – pregmatch Mar 12 '14 at 16:39

When you start SQL*Plus, you need a username and password to login to an Oracle Database schema. Your username and password identify you as an authorized user of the Oracle Database schema.

The database administrator (DBA) is responsible for creating your database account with the necessary privileges and giving you the username and password that enables you to access your account.

share|improve this answer

If using PostgreSQL then you can specify the "trust" method for your localhost network in the "pg_hba.conf" file. For MySQL there may be something similar, I'm not sure (hopefully someone here who's familiar with whatever database you're using can help with this if it's not PostgreSQL).

share|improve this answer
database is oracle – sam Mar 1 '11 at 6:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .