5

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

The database is Oracle.

0

4 Answers 4

3

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.

3
  • +1 thx for introducing "OS Authentication". Did not know about it. Will have plenty of opportunity to use it. Mar 1, 2011 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, 2011 at 18:35
  • Indeed I've implemented OID in the past. Just forgot about it... :-( I'll dust off this domain tomorrow. Mar 1, 2011 at 21:16
1

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

Example on a Unix env:

$ export ORACLE_SID=MYDB
$ sqlplus /nolog

SQL*Plus: Release...

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

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.

2
  • 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, 2011 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, 2014 at 16:39
1

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.

0

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).

1
  • database is oracle
    – sam
    Mar 1, 2011 at 6:13

You must log in to answer this question.

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