1、connect DB failed with ORA-12154 due to User Password have “@” (at mark) char
对于ORA-12nnn错误并不陌生,ORA-12154也是如配置tsnnames.ora 的alias错误常见,但是今天这个案例“若不是亲眼所见,我是万万不敢相信”, 在sqlplus中使用EZCONNECT尝试数据库时总时提示ora-12154, 而部分用户或jdbc应用使用相同用户可以正常链接。
ORA-12154: TNS:could not resolve the connect identifier specified
分析思路
- tnsping tnsnames.ora中配置的alias name或ezconnect串如tnsping ip:port
- 服务器登录排除client version或tnsnames.ora配置错误
- 不使用tns排除监听问题
- 临时创建个用户测试,给create session权限
下面记录一下这个案例 环境oracle 11.2.0.4 rac on linux
在检查了EZCONNECT串配置没有问题后,发现密码中包含@符号,而@符号就是使用tns链接时的字符,即使使用了“”引号括起来一样失败,于是我创建了个新用户test验证一下@这个字符
[oracle@testos:/home/oracle]$sqlplus hr/"hr"@192.168.1.59:1521/testdb
SQL*Plus: Release 12.2.0.1.0 Production on Sat Sep 16 17:12:54 2023
Copyright (c) 1982, 2016, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
SQL>
#Note:可见使用相同的ezconnect可以链接, 下面修改密码,密码中带@符号
SQL> conn / as sysdba
Connected.
sys@testdb(47)> alter user hr identified by "test@1234";
User altered.
#EZCONNECT方式连接
[oracle@testos:/home/oracle]$sqlplus hr/"test@1234"@192.168.1.59:1521/testdb
SQL*Plus: Release 12.2.0.1.0 Production on Sat Sep 16 17:14:55 2023
Copyright (c) 1982, 2016, Oracle. All rights reserved.
ERROR:
ORA-12154: TNS:could not resolve the connect identifier specified
Enter user-name:
#sqlplus连接也报错
[oracle@testos:/home/oracle]$sqlplus hr/"test@1234"
SQL*Plus: Release 12.2.0.1.0 Production on Sat Sep 16 17:19:05 2023
Copyright (c) 1982, 2016, Oracle. All rights reserved.
ERROR:
ORA-12543: TNS:destination host unreachable
Enter user-name:
#本地使用如下方式连接可以
[oracle@testos:/home/oracle]$sqlplus /nolog
SQL*Plus: Release 12.2.0.1.0 Production on Sat Sep 16 17:18:20 2023
Copyright (c) 1982,