Oracle
如何使用 Oracle Developer VM 連接到 root
我有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 只是想讓連接到
ORCL
PDB 變得簡單——而不是真正解釋事情是如何工作的。