in reply to Re: Connecting 'as sysdba' using DBD::Oracle
in thread Connecting 'as sysdba' using DBD::Oracle

Hi,

Your solution work because technically you are supplying the username and password which simulates connecting from the network to the database

I believe the issue here is if you are going to use the script to run locally on the server, there should not be a need to supply username and password because you are already on the server itself. The main idea for this is to not having to specify passwords on your scripts for security reason.

  • Comment on Re^2: Connecting 'as sysdba' using DBD::Oracle

Replies are listed 'Best First'.
Re^3: Connecting 'as sysdba' using DBD::Oracle
by Anonymous Monk on May 12, 2014 at 20:22 UTC
    I know that this is an old thread, but I was having the same problem and Google popped it to the top of the list when I searched for 'perl oracle connect as sysdba'. Just in case anyone else starts looking for an answer to this, the solution is to use a dsn of 'dbi:Oracle:' and undef for the username and password. Provided that you are running as oracle (or are a member of the dba group) on the host where the database is running and you have the ORACLE_SID variable set properly and you use the ora_session_mode => ORA_SYSDBA pair in the connection hash you will connect OK. At least that worked for me.
      I have some insight into this now. I did an strace of the process and the short answer is that there is conflicting posts online about the right way to do this.

      When installing DBD::Oracle, the advice is to build it against the Oracle Instant Client so that database upgrades don't break DBD::Oracle. When you need DBD::Oracle *and* you need to connect '/ as sysdba', you can't use the instant client because you are requesting an internal connection to the database. This attempts to exec the $ENV{ORACLE_HOME}/bin/oracle binary which does not exist.

      For this to work, you have to build/link against the full database install.

      Thanks, this suggestion helped me to connect as sysdba..