我已经设置了Oracle数据库,但我遇到了以下方式的连接问题:
sqlplus CISADM/CISADM@<IP>:1521/PSRM
sqlplus CISADM@PSRM
通过以上两个选项,我成功连接到数据库。虽然,当我尝试连接为:
sqlplus CISADM@<IP>:1521/PSRM
我收到以下错误:
ORA-12504:TNS:听众没有获得CONNECT_DATA中的SERVICE_NAME
我可以使用IP或主机名执行ping,成功地使用IP和主机名tnsping。
我的tnsnames.ora文件:
PSRM =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = <IP>)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = PSRM)
)
)
我的sqlnet.ora文件:
SQLNET.AUTHENTICATION_SERVICES= (NTS)
NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
我从客户端PC连接到位于VM中的数据库。以上文件来自客户端
VM托管数据库的文件:
的tnsnames.ora:
PSRM =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = <IP>)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = PSRM)
)
)
的listener.ora
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = <IP>)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
有什么想法吗?
答案 0 :(得分:2)
你应该这样运行:
sqlplus CISADM@\"<IP>:1521/PSRM\"
重要提示:服务器开头和结尾的\"
:端口/服务是语法的一部分。