解决办法:修改环境变量的配置
原来环境变量TNS_ADMIN如下:即配置的是客户端instantclient的
现在该为Oracle服务器的,
D:appmiracleproduct11.2.0dbhome_2NETWORKADMIN
再来模拟一下问题:
条件:
1、环境变量中TNS_ADMIN为客户端instantclient的,即D:installinstantclientinstantclient_19_12NETWORKADMIN
2、D:installinstantclientinstantclient_19_12NETWORKADMIN目录下的tnsnames.ora文件内容如下:
ORCL1 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = orcl) ) )
当我们修改ORCL1为ORCL时,
ORCL = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = orcl) ) )
此时,用PLSQL访问Oracle数据库,
此时会报错:
解决办法:将环境变量的TNS_ADMIN的变量值改为Oracle服务的,即D:appmiracleproduct11.2.0dbhome_2NETWORKADMIN,
再重启如下四个Oracle服务:
再次用PLSQL访问Oracle数据库,此时就可以登录了。