laravel-oci8 icon indicating copy to clipboard operation
laravel-oci8 copied to clipboard

How to connect to Oracle using SYS AS SYSDBA

Open Sandy007-sys opened this issue 5 years ago • 3 comments

Summary of problem or feature request

How do I connect to Oracle database using SYS AS SYSDBA username in config/database.php file

Code snippet of problem

as I tried using 'username' => 'SYS /AS SYSDBA', 'password' => 'my sys password',

again tried in various forms but it gives following error.. Oci8Exception ORA-28009: connection as SYS should be as SYSDBA or SYSOPER

kindly provide with dummy/test config/database.php using SYS username Thanks

System details

  • Operating System : Windows 10 Pro 64 bit
  • PHP Version : 7.3.12
  • Laravel Version : 5.4
  • Laravel-OCI8 Version : 5.4

Sandy007-sys avatar Jun 22 '20 04:06 Sandy007-sys

Sorry for late response, I personally haven't tried this yet. Were you able to solve this?

yajra avatar Dec 06 '20 12:12 yajra

I ran into this same issue when trying to connect to a fresh local Oracle database in a Docker container. I was able to get past the issue mentioned above by setting the username to 'SYS AS SYSDBA', but then I was getting the invalid username/password error (ORA-01017). It turns out that when you are trying to connect to a database using oci8 with the sys user, you need to do a few things:

  • Enable privileged connections in the php.ini file (oci8.privileged_connect = On)
  • Use 'SYS' as the username (no need for 'SYS AS SYSDBA' here)
  • In the oci_connect function, pass in the session_mode argument as OCI_SYSDBA or OCI_SYSOPER

See the session_mode parameter in the PHP docs for more info about this: https://www.php.net/manual/en/function.oci-connect.php

Now I'm just not sure if it is currently possible to set the session_mode using this packages interface

Corey28 avatar Feb 04 '21 16:02 Corey28

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Oct 17 '22 04:10 github-actions[bot]

This issue was closed because it has been inactive for 7 days since being marked as stale.

github-actions[bot] avatar Oct 25 '22 04:10 github-actions[bot]