Error: ORA-12154: TNS:could not resolve the connect identifier specified when entering username and password in sql plus

Error: ORA-12154: TNS:could not resolve the connect identifier specified when entering username and password in sql plus

我正在尝试使用 sql plus 登录到我的 oracle 数据库。但是出现这样的错误

ORA-12154: TNS:could not resolve the connect identifier specified

这是我的 tnsnames.ora file, sqlnet.ora file and listener.ora 文件。这是因为我在我的密码中使用了符号“@”之类的。我仍然无法从 Whosebug 找到任何解决方案。我希望有人可以帮助我。我会在 sql plus.

中向您展示我是如何做到的
SQL*Plus: Release 18.0.0.0.0 - Production on Fri Nov 20 00:26:52 2020
Enter user-name: sys as sysdba
Enter password:
ERROR:
ORA-12154: TNS:could not resolve the connect identifier specified

供您参考,我只是一名刚刚学习如何设置 oracle 数据库的学生。

您没有显示实际的 sqlplus 连接命令。但是由于您在密码中询问了“@”,所以这绝对可以而且 most 通常会导致您提到的确切错误。 '@'用作分隔符来标记网络服务名称(tnsnames 条目)的开头。例如:

oracle:orcl$ sqlplus scott/myp@ssword

SQL*Plus: Release 12.2.0.1.0 Production on Thu Nov 19 11:31:03 2020

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

ERROR:
ORA-12154: TNS:could not resolve the connect identifier specified

在此示例中,它会在我的密码中看到“@”并假设密码实际上是 'myp' 并且它会查找 'ssword' 的 tnsnames.ora 条目

最重要的是,您的密码验证功能应该不允许“@”。

但还要注意,在此示例中,您连接的是 'as sysdba'。为此,您实际上根本不需要任何凭据,因为您应该使用属于 'dba' 组的 OS 帐户,因此可以使用 os 凭据进行连接:

oracle:orcl$ sqlplus

SQL*Plus: Release 12.2.0.1.0 Production on Thu Nov 19 11:35:27 2020

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

Enter user-name: / as sysdba

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> show user
USER is "SYS"
SQL> 

但是,除非您绝对需要更高级别的访问权限,否则您真的永远不应该以 SYS 身份连接。当你是 SYS 的时候,你就是在没有网的情况下在高线上玩杂耍电锯。