关于Oracle 12C pdb用户无法登录的问题
新装了oracle12c,对新的CDB和PDB用户如何登录一直一头雾水,经过一晚上的查找,终于解决。
-
sqlplus /nolog -> conn /as sysdba 登录到oracle
-
将session切换到PDB下alter session set container=pdborcl
-
建立表空间create tablespace tablespace_name datafile '/home/oracle/var/data/tablespace_name.dbf' size 500m autoextend on;
-
查看表空间select tablespace_name,file_id,file_name from dba_data_files;
-
建立用户create user table_name identified by password default tablespace tablespace_name;
-
对用户授权grant dba to toolbar;
-
提交commit;
-
conn toolbar/toolbar@pdborcl
ERROR:
ORA-01017: invalid username/password; logon denied始终无法登录
-
设置TNS_ADMIN
export TNS_ADMIN=/home/oracle/app/oracle/product/12.1.0/dbhome_2/network/admin
依旧没有解决
-
conn toolbar/toolbar@orcl
ERROR:
ORA-12514: TNS:listener does not currently know of service requested in connect
descriptor出现TNS错误,应该是TNS脚本的问题
-
查看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 -
在tnsnames.ora里面加入
PDBORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = pdborcl.localdomain)
)
) -
conn toolbar/toolbar@PDBORCL
Connected.OK啦
^_^祝玩得愉快