Oracle

如何使用 Oracle Developer VM 連接到 root

  • May 14, 2018

我有Oracle Database App Development VM (12c) 並正在嘗試創建一個新容器。具體來說:

conn / as sysdba
create pluggable database pdborcl admin user system identified by oracle FILE_NAME_CONVERT=('/u01/app/oracle/oradata/cdb1/pdbseed/', '/u01/app/oracle/oradata/cdb1/pdb2'');

但是,我無法連接到根容器。以上conn吐出:

 URL           = jdbc:oracle:oci8:@(DESCRIPTION =    (ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))    (CONNECT_DATA =      (SERVER = DEDICATED)      (SERVICE_NAME = orcl)    )  )
 Error Message = ORA-01017: invalid username/password; logon denied
 USER          = 
 URL           = jdbc:oracle:thin:@(DESCRIPTION =    (ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))    (CONNECT_DATA =      (SERVER = DEDICATED)      (SERVICE_NAME = orcl)    )  )
 Error Message = ORA-01017: invalid username/password; logon denied

Warning: You are no longer connected to ORACLE.

sqlplus / as sysdba返回:

ERROR:
ORA-01017: invalid username/password; logon denied

使用sqlplus system as sysdba登錄登錄連接ORCL

不工作的原因sqlplus / as sysdba是:

[oracle@localhost ~]$ grep -i two_task .bashrc
if test "m$DONOTSETTWO_TASK" = "m"
       export TWO_TASK=ORCL
[oracle@localhost ~]$ grep -i two_task .bashrc -A 1
if test "m$DONOTSETTWO_TASK" = "m"
       then
       export TWO_TASK=ORCL
       fi
[oracle@localhost ~]$ echo $TWO_TASK 
ORCL

SQL*Plus 連接自動連接到TWO_TASK環境變數中定義的 TNS 別名。設置後,sqlplus / as sysdba不起作用。

這就像嘗試這個(不會工作):

sqlplus /@ORCL as sysdba

要“修復”這個:

[oracle@localhost ~]$ unset TWO_TASK
[oracle@localhost ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Fri May 11 15:20:59 2018

Copyright (c) 1982, 2016, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> 

您不能使用 SQL*Plus 直接連接到 PDB,您需要使用 TNS 別名或 EZCONNECT。設置TWO_TASK會處理這個問題,因此您可以sqlplus hr/hr直接登錄到 PDB,而無需手動指定其地址。

我猜 Oracle 只是想讓連接到ORCLPDB 變得簡單——而不是真正解釋事情是如何工作的。

引用自:https://dba.stackexchange.com/questions/206500