why system login is denied in cx_Oracle.SYSDBA mode

余生颓废 提交于 2019-12-24 08:06:26

问题


I am trying to connect to Oracle 12c through cx_Oracle module. Login using following code works where no mode is mentioned in cx_Oracle.connect method

import cx_Oracle                                                                
ip = 'ip'                                                             
port='1521'                                                                    
SID='orcl'                                                                     
dsn_tns = cx_Oracle.makedsn(ip, port, SID)                                     
db = cx_Oracle.connect('system', 'password', dsn_tns)

but for following way it shows invalid login error for cx_Oracle.SYSDBA mode.

db = cx_Oracle.connect('system', 'password', dsn_tns, cx_Oracle.SYSDBA) 

Error:

cx_Oracle.DatabaseError: ORA-01017: invalid username/password; logon denied

What am I missing here ?? credentials are same. I tried login manually as follows and is successful

>sqlplus system/password as sysdba

回答1:


If you connect as user sys, you need to use the cx_Oracle.SYSDBA mode:

conn = cx_Oracle.connect('sys', 'password', dsn_tns, cx_Oracle.SYSDBA)
ok

conn = cx_Oracle.connect('sys', 'password', dsn_tns)
ORA-28009: connection as SYS should be as SYSDBA or SYSOPER

However, if you connect as user system, you mustn't use the cx_Oracle.SYSDBA mode:

conn = cx_Oracle.connect('system', 'password', dsn_tns)
ok

conn = cx_Oracle.connect('system', 'password', dsn_tns, cx_Oracle.SYSDBA)
ORA-01017: invalid username/password; logon denied

The difference of the users sys and system is explained for instance here.



来源:https://stackoverflow.com/questions/50812891/why-system-login-is-denied-in-cx-oracle-sysdba-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!