sqlnet.ora文件中的NAMES.DIRECTORY_PATH= (TNSNAMES,EZCONNECT),添加ezconnect参数值,所以如果指定数据库实例,必须要跟上主机ip地址。请参考【Easy Connect Naming】。因此正确的写法是:CONNECTusername/password@host[:port][/service_name]
例如connect sys/oracle@192.168.135.243/orcl as sysdba
解决方法:
连接数据库时需要指定主机ip地址:connect sys/orcl@192.168.135.243/orcl as sysdba
相关知识: 以下知识来源于oracle官方文档
Naming MethodDescriptionLocal Naming
Resolves anetservice namestored in atnsnames.orafile stored on a client
Local naming is most appropriate for simple distributed networks with a small number of services that change infrequently. See Also:"Configuringthe Local Naming Method"
Directory Naming
Resolves a databaseservicename, net service name, ornet service aliasstoredin a centralized LDAP-compliant directory server See Also:"Configuringthe Directory Naming Method"
Easy Connect Naming
Enables clients to connect to a database server without any configuration. Clients use a connect string for a simple TCP/IP address, consisting of a host name and optional port and service name:
CONNECTusername/password@host[:port][/service_name]
This method is recommended for simple TCP/IP environments. See Also:"Usingthe Easy Connect Naming Method"
External Naming
Resolves service information stored in an a third-party naming service See Also:"ConfiguringExternal Naming Methods"