Oracle12c(PDB中) ORA-01017: invalid username_password; logon denied

2024-12-05Oracle / RAC / 性能优化

问题背景描述:

view plaincopy

  1. SQL> alter session set container=pdbwyzc; –切换pdb
  2. SQL> define username=eoda
  3. SQL> define usernamepwd=foo
  4. SQL> create user &&username identified by &&usernamepwd;
  5. SQL> grant dba to &&username;
  6. SQL> grant execute on dbms_stats to &&username;
  7. SQL> grant select on V_$STATNAME to &&username;
  8. SQL> grant select on V_$MYSTAT to &&username;
  9. SQL> grant select on V_$LATCH to &&username;
  10. SQL> grant select on V_$TIMER to &&username;
  11. SQL> conn &&username/&&usernamepwd –无法连接
  12. ERROR:
  13. ORA-01017: invalid username/password; logon denied
  14. 14.

  15. SQL> select username, account_status from dba_users; –查看用户状态正常
  16. USERNAME ACCOUNT_STATUS
  17. —————————— ——————————–
  18. EODA OPEN

**解决方法:

**

view plaincopy

  1. SQL> select name,pdb from v$services; –查看service_name
  2. 2.

  3. NAME
  4. —————————————————————-
  5. PDB
  6. ——————————
  7. pdbwyzc
  8. PDBWYZC
  9. [oracle@luo ~]$ vi /u01/oracle/12c/network/admin/tnsnames.ora
  10. –添加以下段落
  11. PDBWYZC =
  12. (DESCRIPTION =
  13. (ADDRESS = (PROTOCOL = TCP)(HOST = luo)(PORT = 1524))
  14. (CONNECT_DATA =
  15. (SERVER = DEDICATED)
  16. (SERVICE_NAME = pdbwyzc)
  17. )
  18. )
  19. [oracle@luo ~]$ rlwrap sqlplus / as sysdba
  20. 20.

  21. SQL*Plus: Release 12.1.0.2.0 Production on Sat Dec 3 14:28:31 2016
  22. 22.

  23. Copyright (c) 1982, 2014, Oracle. All rights reserved.
  24. 24. 25.

  25. Connected to:
  26. Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 – 64bit Production
  27. With the Partitioning, Automatic Storage Management, OLAP, Advanced Analytics
  28. and Real Application Testing options
  29. 30.

  30. SQL> alter session set container=pdbwyzc;
  31. 32.

  32. Session altered.
  33. 34.

  34. SQL> conn eoda/foo@pdbwyzc –成功连接
  35. Connected.