【问题标题】:sqlplus can not connect to oracle using information in tnsnames.orasqlplus 无法使用 tnsnames.ora 中的信息连接到 oracle
【发布时间】:2013-09-15 16:37:06
【问题描述】:

我可以登录

sqlplus / as sysdba

然后我使用startup启动实例,我也可以使用启动PDB

startup pluggable database pdborcl 

在终端中,echo $ORACLE_SID 得到 ora12cr1

但我无法使用

登录
sqlplus  /@ora12cr1 as sysdba

我得到 ORA-01017:无效的用户名/密码;登录被拒绝。下面是我的 tnsnames.ora:

ORA12CR1=
  (DESCRIPTION=
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))
    (CONNECT_DATA=
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl.cn.oracle.com)
    )
  )

PDBORCL =
 (DESCRIPTION =
   (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))
     (CONNECT_DATA =
       (SERVICE_NAME = pdborcl.cn.oracle.com)
     )
 )

oracle 12cr1 安装在我的本地机器上。

lsnrctl 状态获取:

LSNRCTL for Linux: Version 12.1.0.1.0 - Production on 11-SEP-2013 23:02:57

Copyright (c) 1991, 2013, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 12.1.0.1.0 - Production
Start Date                11-SEP-2013 22:40:09
Uptime                    0 days 0 hr. 22 min. 48 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/12.1.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=localhost.localdomain)(PORT=5500))(Security=(my_wallet_directory=/u01/app/oracle/admin/orcl/xdb_wallet))(Presentation=HTTP)(Session=RAW))
Services Summary...
Service "orcl.cn.oracle.com" has 1 instance(s).
  Instance "ora12cr1", status READY, has 1 handler(s) for this service...
Service "orclXDB.cn.oracle.com" has 1 instance(s).
  Instance "ora12cr1", status READY, has 1 handler(s) for this service...
Service "pdborcl.cn.oracle.com" has 1 instance(s).
  Instance "ora12cr1", status READY, has 1 handler(s) for this service...
The command completed successfully

SQL> show pdbs

    CON_ID CON_NAME           OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
     3 PDBORCL            READ WRITE NO

alter session set container = pdborcl

也可以。

【问题讨论】:

  • 那么,当您在 sqlplus 命令行中实际传入用户名/密码时会发生什么?

标签: linux oracle sqlplus tnsnames oracle12c


【解决方案1】:

我正在使用

sqlplus sys@pdborcl as sysdba

并输入密码。

show con_name;

产生价值

CON_NAME
------------------------------
PDBORCL

【讨论】:

    【解决方案2】:

    使用/ AS SYSDBA 将像在container database 级别(CDB) 的先前版本中一样工作。但它无法通过 sqlplus 连接到没有密码的pluggable database (PDB)。

    实现此目的的最简单方法是使用“/ as SYSDBA”继续连接,但使用ALTER SESSION SET CONTAINER 命令在脚本中设置特定容器。

    sqlplus / as sysdba <<EOF
    
    ALTER SESSION SET CONTAINER = pdb1;
    
    -- Perform actions as before...
    SHOW CON_NAME;
    
    EXIT;
    EOF
    

    您也可以参考这篇文章了解更多信息Multitenant : Running Scripts Against Container Databases (CDBs) and Pluggable Databases (PDBs) in Oracle Database 12c Release 1 (12.1)

    【讨论】:

      【解决方案3】:

      试试

      sqlplus /@localhost.localdomain/orcl.cn.oracle.com as sysdba

      如果这是您要登录的服务(不确定我是否完全理解您的问题)。

      【讨论】:

      • 它没有用adona9。其实我试过 sqlplus /@(DESCRIPTION=(ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))(CONNECT_DATA=(SERVER = DEDICATED)(SERVICE_NAME = orcl.cn.oracle.com ))) 作为 sysdba。还是失败了。
      猜你喜欢
      • 1970-01-01
      • 2016-09-03
      • 1970-01-01
      • 2012-12-21
      • 2012-01-16
      • 1970-01-01
      • 2013-03-17
      • 1970-01-01
      • 2023-03-22
      相关资源
      最近更新 更多