1、联网设置是否正确 2、服务器监听是否开启 3、tnslisteners中是serivce_name(/)还是sid_name(:)

1、新装的oracle12c 只能通过localhost来连接,通过Net Manager配置之后,如下图所示:

Oracle12c 通过IP访问数据出现ORA-12505错误-冯金伟博客园

Oracle12c 通过IP访问数据出现ORA-12505错误-冯金伟博客园

2、然后重启以下服务,如下图所示:  

Oracle12c 通过IP访问数据出现ORA-12505错误-冯金伟博客园

3、使用sql developer仍然无法通过IP连接,出现:状态: 失败 -测试失败: Listener refused the connection with the following error: ORA-12505, TNS:listener does not currently know of SID given in connect descriptor,如下图所示:

Oracle12c 通过IP访问数据出现ORA-12505错误-冯金伟博客园

4、编辑D:InstallFileOracle12appAdministratorproduct12.1.0dbhome_1NETWORKADMIN目录下的listener.ora文件,然后将:

# listener.ora Network Configuration File: D:InstallFileOracle12appAdministratorproduct12.1.0dbhome_1NETWORKADMINlistener.ora # Generated by Oracle configuration tools.
SID_LIST_LISTENER =   (SID_LIST =     (SID_DESC =       (SID_NAME = CLRExtProc)       (ORACLE_HOME = D:InstallFileOracle12appAdministratorproduct12.1.0dbhome_1)       (PROGRAM = extproc)       (ENVS = “EXTPROC_DLLS=ONLY:D:InstallFileOracle12appAdministratorproduct12.1.0dbhome_1inoraclr12.dll”)     )     )   )
LISTENER =   (DESCRIPTION_LIST =     (DESCRIPTION =       (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.33)(PORT = 1521))     )     (DESCRIPTION =       (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))     )   )
ADR_BASE_LISTENER = D:InstallFileOracle12appAdministratorproduct12.1.0dbhome_1log

更改为(红色字体部分):

# listener.ora Network Configuration File: D:InstallFileOracle12appAdministratorproduct12.1.0dbhome_1NETWORKADMINlistener.ora # Generated by Oracle configuration tools.
SID_LIST_LISTENER =   (SID_LIST =     (SID_DESC =       (SID_NAME = CLRExtProc)       (ORACLE_HOME = D:InstallFileOracle12appAdministratorproduct12.1.0dbhome_1)       (PROGRAM = extproc)       (ENVS = “EXTPROC_DLLS=ONLY:D:InstallFileOracle12appAdministratorproduct12.1.0dbhome_1inoraclr12.dll”)     ) (SID_DESC =       (GLOBAL_DBNAME = ORCL)       (ORACLE_HOME = D:InstallFileOracle12appAdministratorproduct12.1.0dbhome_1)       (sid_name = ORCL)     )   )
LISTENER =   (DESCRIPTION_LIST =     (DESCRIPTION =       (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.33)(PORT = 1521))     )     (DESCRIPTION =       (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))     )   )
ADR_BASE_LISTENER = D:InstallFileOracle12appAdministratorproduct12.1.0dbhome_1log

保存之后重启第2步的两个服务。

5、重新进行测试,测试成功,如下图所示:

Oracle12c 通过IP访问数据出现ORA-12505错误-冯金伟博客园

注意:此是连接数据库orcl的配置,如果是新建测数据库要重新设置。