报错:连接oracle数据库时,出现ORA-12514: TNS: 监听程序当前无法识别连接描述符中请求的服务
解决方法:
1、重启oracle相关服务,尝试重新连接,若未解决进行第2步
2、正确设置数据库服务器中的listener.ora文件,添加相应的实例,重启数据库服务,尝试重新连接
示例
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = CLRExtProc)
(ORACLE_HOME = D:\oracle\product\11.2.0\db_1)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME = ORCL)
(ORACLE_HOME = D:\oracle\product\11.2.0\db_1)
(SID_NAME = ORCL)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.1)(PORT = 1521))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
其中在文件的SID_LIST中添加粗体片段,ORACLE_HOME要填写自己的相关路径,SID_NAME是数据库实例,一般本地都是ORCL,其中GLOBAL_DBNAME为全局数据库名,可以与SID不同。
3、确认数据库服务器或客户端的tnsnames.ora文件
如数据库地址为:127.0.1.1:1521/orcl,通过设置tnsnames.ora,为它起别名为:database,就可以用database代替了
ORCL =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.1)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
database =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.1)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl) #数据库实例名称
)
)
sqlplus 用户名/密码@ip:1521/服务名
sqlplus 用户名/密码@别名