ITPub博客

首页 > 应用开发 > IT综合 > 口令中含@的问题!

口令中含@的问题!

原创 IT综合 作者:warehouse 时间:2008-04-01 09:44:56 0 删除 编辑

当口令中包含@时不能通过sqlplus username/"password"连上数据库,但是可以通过sqlplus username(@tns)之后再输入password(切记password用双引号扩起来)正常连接数据库;也可以先进入sqlplus环境:sqlplus /nolog之后再connect username/"password"@tns连接数据库!

[@more@]

SQL> create user test identified by "test@123";

用户已创建。

SQL> grant dba to test;

授权成功。

SQL> exit
从 Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options 断
开

C:>sqlplus test/"test@123"

SQL*Plus: Release 11.1.0.6.0 - Production on 星期二 4月 1 09:37:22 2008

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

ERROR:
ORA-12170: TNS: 连接超时


请输入用户名:
ERROR:
ORA-01017: 用户名/口令无效; 登录被拒绝


请输入用户名:
ERROR:
ORA-01017: 用户名/口令无效; 登录被拒绝


SP2-0157: 在 3 次尝试之后无法连接到 ORACLE, 退出 SQL*Plus

C:>sqlplus /nolog

SQL*Plus: Release 11.1.0.6.0 - Production on 星期二 4月 1 09:38:17 2008

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

SQL> connect test/"test@123"
已连接。
SQL> exit
从 Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options 断
开

C:>sqlplus test/"test@123"

SQL*Plus: Release 11.1.0.6.0 - Production on 星期二 4月 1 09:39:09 2008

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

ERROR:
ORA-12170: TNS: 连接超时
--此时输入口令test@123

请输入用户名: test
输入口令:
ERROR:
ORA-12170: TNS: 连接超时
--此时输入口令"test@123"

请输入用户名: test
输入口令:

连接到:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> connect xys/manager
已连接。
SQL> alter user test identified by "test/123";

用户已更改。
--凡是口令中含有特殊字符的都需要使用双引号
SQL> connect test/test/123
SP2-0306: 选项无效。
用法: CONN[ECT] [logon] [AS {SYSDBA|SYSOPER|SYSASM}]
其中 ::= [/][@] [edition=value]
| /
--但是当口令中含有@特殊字符时却和其它特殊字符不太一样,当口令中
包含@时通过sqlplus username/password连接时oracle把password中的@
后面的剩下的串当tns来对待,从不能连上的错误提示中我们能够清楚的发现:
"ERROR:
ORA-12170: TNS: 连接超时"

当口令中含有除了@之外的其它字符是通过sqlplus username/password连接
时如果passoword不加双引号,此时直接给出的错误提示是:"使用 SQL*Plus 执行 SQL, PL/SQL 和 SQL*Plus 语句。

用法 1: sqlplus -H | -V

-H 显示 SQL*Plus 版本和
用法帮助。
-V 显示 SQL*Plus 版本。..........."
等sqlplus使用帮助的提示。

SQL> connect test/"test/123"
已连接。
SQL> exit
从 Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options 断
开

C:>sqlplus test/"test/123"

提示如下:

--==============================================

SQL*Plus: Release 11.1.0.6.0 - Production on 星期二 4月 1 09:46:10 2008

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


SQL*Plus: Release 11.1.0.6.0 - Production

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

使用 SQL*Plus 执行 SQL, PL/SQL 和 SQL*Plus 语句。

用法 1: sqlplus -H | -V

-H 显示 SQL*Plus 版本和
用法帮助。
-V 显示 SQL*Plus 版本。

用法 2: sqlplus [ [

-C 将受影响的命令的兼容性设置为
指定的版本。该版本具有
"x.y[.z]" 格式。例如, -C 10.2.0
-F 为 RAC 环境启用故障转移模式。
-L 只尝试登录一次, 而不是
在出错时再次提示。
-M "" 设置输出的自动 HTML 标记。选项
的格式为:
HTML [ON|OFF] [HEAD text] [BODY text] [TABLE text]
[ENTMAP {ON|OFF}] [SPOOL {ON|OFF}] [PRE[FORMAT] {ON|OFF}]
-R 设置受限模式, 以禁用与文件系统交互的
SQL*Plus 命令。级别可以
是 1, 2 或 3。最高限制级别为 -R 3, 该级别
禁用与文件系统交互的
所有用户命令。
-S 设置无提示模式, 该模式隐藏
命令的 SQL*Plus 标帜, 提示和回显
的显示。

为: ([/][@] | /)
[AS SYSDBA | AS SYSOPER | AS SYSASM] | /NOLOG | [EDITION=value]

指定数据库帐户用户名, 口令和数据库连接
的连接标识符。如果没有连接
标识符, SQL*Plus 将连接到默认数据库。

AS SYSDBA, AS SYSOPER 和 AS SYSASM 选项是数据库
管理权限。

的形式可以是 Net 服务名
或轻松连接。

@[ | [//]Host[:Port]/]

是服务的简单名称, 它解析
为连接描述符。

示例: 使用 Net 服务名连接到数据库, 且
数据库 Net 服务名为 ORCL。

sqlplus myusername/mypassword@ORCL

Host 指定数据库服务器计算机的主机名或 IP
地址。

Port 指定数据库服务器上的监听端口。

指定要访问的数据库的
服务名。

示例: 使用轻松连接连接到数据库, 且
服务名为 ORCL。

sqlplus myusername/mypassword@Host/ORCL

/NOLOG 选项可启动 SQL*Plus 而不连接到
数据库。

EDITION 指定应用程序
版本的值

为: @|[.] [ ...]

使用将分配给脚本中的替代变量的指定参数
从 Web 服务器 (URL) 或本地文件系统 (filename.ext)
运行指定的 SQL*Plus 脚本。

在启动 SQL*Plus 并且执行 CONNECT 命令后, 将运行站点概要
文件 (例如, $ORACLE_HOME/sqlplus/admin/glogin.sql) 和用户概要文件
(例如, 工作目录中的 login.sql)。这些文件
包含 SQL*Plus 命令。

有关详细信息, 请参阅 SQL*Plus 用户指南和参考。

--==============================================

SQL> alter user test identified by "test@123";

用户已更改。

SQL> connect test/"test@123"@db11
已连接。
SQL> exit
从 Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options 断
开

C:>sqlplus test/"test@123"@db11

SQL*Plus: Release 11.1.0.6.0 - Production on 星期二 4月 1 09:49:04 2008

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

ERROR:
ORA-12154: TNS: 无法解析指定的连接标识符


请输入用户名: test@db11

--输入口令test@123
输入口令:

连接到:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL>

另外在plsql developer中测试时发现password不需要加""

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/19602/viewspace-1001719/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2007-12-07

  • 博文量
    717
  • 访问量
    5366312