PowerShell连接自治数据库时出现问题
我已经能够连接到OCI上的Autonomous Database,并且也能通过网页访问。
然而,我无法在我的个人Windows笔记本上通过PowerShell使用SQL*Plus 21c进行连接。我已成功下载钱包并配置了 tnsnames.ora 和 sqlnet.ora。主机连接工作正常,因此没有网络问题。唯一的问题出在钱包中的 tnsnames.ora 的服务名上——当我使用该服务名时,SQL*Plus连接失败。
PS G:\\WINDOWS.X64_212000_db_home\\instantclient_21_20\> sqlplus admin/"PWD"@//adb.ap-mumbai-1.oraclecloud.com:1522/wrlvwfcfuxzhsfv_testing_medium.adb.oraclecloud.com
SQL*Plus: Release 21.0.0.0.0 - Production on Fri Apr 17 17:24:02 2026
Version 21.20.0.0.0
Copyright (c) 1982, 2022, Oracle. All rights reserved.
错误:
ORA-12154: TNS:无法解析指定的连接标识符
tnsnames.ora:
testing_high = (description= (retry_count=20)(retry_delay=3)(address=(protocol=tcps)(port=1522)(host=adb.ap-mumbai-1.oraclecloud.com))(connect_data=(service_name=wrlvwfcfuxzhsfv_testing_high.adb.oraclecloud.com))(security=(ssl_server_dn_match=yes)))
testing_medium = (description= (retry_count=20)(retry_delay=3)(address=(protocol=tcps)(port=1522)(host=adb.ap-mumbai-1.oraclecloud.com))(connect_data=(service_name=wrlvwfcfuxzhsfv_testing_medium.adb.oraclecloud.com))(security=(ssl_server_dn_match=yes)))
testing_low = (description= (retry_count=20)(retry_delay=3)(address=(protocol=tcps)(port=1522)(host=adb.ap-mumbai-1.oraclecloud.com))(connect_data=(service_name=wrlvwfcfuxzhsfv_testing_low.adb.oraclecloud.com))(security=(ssl_server_dn_match=yes)))
testing_tp = (description= (retry_count=20)(retry_delay=3)(address=(protocol=tcps)(port=1522)(host=adb.ap-mumbai-1.oraclecloud.com))(connect_data=(service_name=wrlvwfcfuxzhsfv_testing_tp.adb.oraclecloud.com))(security=(ssl_server_dn_match=yes)))
testing_tpurgent = (description= (retry_count=20)(retry_delay=3)(address=(protocol=tcps)(port=1522)(host=adb.ap-mumbai-1.oraclecloud.com))(connect_data=(service_name=wrlvwfcfuxzhsfv_testing_tpurgent.adb.oraclecloud.com))(security=(ssl_server_dn_match=yes)))
sqlnet.ora:
WALLET_LOCATION = (SOURCE = (METHOD = file) (METHOD_DATA = (DIRECTORY="G:\\WINDOWS.X64_213000_db_home\\network\\admin\\Wallet")))
SSL_SERVER_DN_MATCH=yes
SQLNET.USE_HTTPS_PROXY=on
解决方案
tnsnames.ora 文件用于将别名解析为连接字符串。 然而 //adb.ap-mumbai-1.oraclecloud.com:1522/wrlvwfcfuxzhsfv_testing_medium.adb.oraclecloud.com 不是一个别名,因此 tnsnames.ora 不会被使用或不需要。
tnsnames.ora 文件在你需要使用时会被考虑。
sqlplus admin/"PWD"@testing_medium
一个可能的问题是,你的 sqlplus 找不到 sqlnet.ora 和 tnsnames.ora 文件。为了解决这个问题,请参考 Determining location of relevant tnsnames.ora file
站内所有文章版权归属LeftHeroAI导航站,无授权禁止任何主体转载、抄袭、复制内容,亦不得私自架设镜像站点。一经侵权,本站将通过法律途径追责。