出于安全的考虑,公司要求密码中存在@等特殊字符的密码编排方式,
但在密码中出现@字符时,如果按照正常sqlplus连接方式登录数据库,会提示ora-12154错误,解析服务名时出错 找不到指定的服务名称。
1. 存在特殊字符@
大致情形如下:
SQL> alter user scott identified by "tiger@123";
User altered.
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
D:\>sqlplus scott/tiger@123@orcl251
SQL*Plus: Release 10.2.0.1.0 - Production on Tue Apr 29 16:09:36 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
ERROR:
ORA-12154: TNS:could not resolve the connect identifier specified
采用下面的方式来处理,可正常登录:
D:\>sqlplus scott/\"tiger@123\"@orcl
2. 存在特殊字符& \ %
大致情况如下:
SQL> set define off
SQL> alter user scott identified by "tiger&123";
User altered.
采用添加双引号方式进行登录处理
D:\>sqlplus scott/"tiger&123"@orcl
SQL*Plus: Release 10.2.0.1.0 - Production on Tue Apr 29 16:16:26 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> select sysdate from dual;
其中\,%可以不加双引号,按照正常方式登录
3. 存在特殊字符$
3.1 $位于密码最后
可以直接使用双引号括起来
sqlplus marlie/"123$"@orcl
3.2 $位于密码中间或开头
因为在linux中$123表示 为变量123的具体值,需要进行转义来处理
sqlplus marlie/123\$123@orcl