重庆思庄Oracle、Redhat认证学习论坛

标题: Oracle密码有@等特殊字符,连接报ORA-12532: TNS:invalid argument [打印本页]

作者: jiawang    时间: 2023-12-8 16:37
标题: Oracle密码有@等特殊字符,连接报ORA-12532: TNS:invalid argument
本帖最后由 jiawang 于 2023-12-8 17:21 编辑

当oracle密码含有特殊字符时,在创建的时候,必须要用双引号把密码包起来才能创建成功
例子:
SQL> create user wj identified by oracle@123;
create user wj identified by oracle@123
                                   *
ERROR at line 1:
ORA-00922: missing or invalid option


必须把密码包起来:
SQL> create user wj identified by "oracle@123";
User created.

SQL>

SQL> grant connect,resource to wj;
Grant succeeded.

连接报错:
SQL> conn wj/oracle@123;
ERROR:
ORA-12532: TNS:invalid argument


Warning: You are no longer connected to ORACLE.

也需要双引号

SQL> conn wj/"oracle@123";
Connected.

使用sqlplus切换到指定的数据库,报错
[oracle@strong admin]$ sqlplus wj/"oracle@123" @ORCL

SQL*Plus: Release 11.2.0.4.0 Production on Fri Dec 8 16:48:30 2023

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

ERROR:
ORA-12532: TNS:invalid argument


正确连接方式:
[oracle@strong admin]$ sqlplus 'wj/"oracle@123"' @ORCL

SQL*Plus: Release 11.2.0.4.0 Production on Fri Dec 8 16:48:44 2023

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SP2-0310: unable to open file "ORCL.sql"
SQL>      

通过单引号将用户密码包起来,用双引号把密码包起来,就可以正常连接数据库啦。

推荐的特殊字符:_ $ #

其他特殊字符密码必须加双引号









欢迎光临 重庆思庄Oracle、Redhat认证学习论坛 (http://bbs.cqsztech.com/) Powered by Discuz! X3.2