关于Oracle 12C pdb用户无法登录的问题

新装了oracle12c,对新的CDB和PDB用户如何登录一直一头雾水,经过一晚上的查找,终于解决。

 

    1. sqlplus /nolog -> conn /as sysdba 登录到oracle

    2. 将session切换到PDB下alter session set container=pdborcl

    3. 建立表空间create tablespace tablespace_name datafile '/home/oracle/var/data/tablespace_name.dbf' size 500m autoextend on;

    4. 查看表空间select tablespace_name,file_id,file_name from dba_data_files;

    5. 建立用户create user table_name identified by password default tablespace tablespace_name;

    6. 对用户授权grant dba to toolbar;

    7. 提交commit;

    8. conn toolbar/toolbar@pdborcl
      ERROR:
      ORA-01017: invalid username/password; logon denied

      始终无法登录

    9. 设置TNS_ADMIN

      export TNS_ADMIN=/home/oracle/app/oracle/product/12.1.0/dbhome_2/network/admin

      依旧没有解决

    10. conn toolbar/toolbar@orcl
      ERROR:
      ORA-12514: TNS:listener does not currently know of service requested in connect
      descriptor

      出现TNS错误,应该是TNS脚本的问题

    11. 查看services,发现应该是pdborcl的服务名有问题

      select name,pdb from v$services;

      NAME                   PDB
      ------------------------------ ------------------------------
      pdborcl.localdomain           PDBORCL
      orclXDB                CDB$ROOT
      orcl.localdomain           CDB$ROOT
      SYS$BACKGROUND               CDB$ROOT
      SYS$USERS               CDB$ROOT

    12. 在tnsnames.ora里面加入

      PDBORCL =
        (DESCRIPTION =
          (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
          (CONNECT_DATA =
            (SERVER = DEDICATED)
            (SERVICE_NAME = pdborcl.localdomain)
          )
        )

    13. conn toolbar/toolbar@PDBORCL
      Connected.

      OK啦

      ^_^祝玩得愉快

posted @ 2018-01-02 08:53  旧巷里的旧少年  阅读(433)  评论(0编辑  收藏  举报