解决办法:修改环境变量的配置

原来环境变量TNS_ADMIN如下:即配置的是客户端instantclient的

 现在该为Oracle服务器的,

D:\app\miracle\product\11.2.0\dbhome_2\NETWORK\ADMIN

 再来模拟一下问题:

条件:

1、环境变量中TNS_ADMIN为客户端instantclient的,即D:\install\instantclient\instantclient_19_12\NETWORK\ADMIN

2、D:\install\instantclient\instantclient_19_12\NETWORK\ADMIN目录下的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:\app\miracle\product\11.2.0\dbhome_2\NETWORK\ADMIN,

 

 再重启如下四个Oracle服务:

 

 再次用PLSQL访问Oracle数据库,此时就可以登录了。

 

posted on 2021-10-08 10:57  周文豪  阅读(3193)  评论(0编辑  收藏  举报