如何配置oracle数据库的连接

时间:2022-04-30 21:54:42

解决oracle数据库“监听程序当前无法识别连接描述符中请求的服务”

 

 

今晚搞了几个小时的oracle配置,现在终于连上了,同时也发现好多人每次重装系统后都得重装oracle,现将我如何处理这一类问题的方法分享如下,嘿嘿,屡试不爽的,更重要的是不用修改ip,直接用本地连接localhost,不论是否联网都可以这样配置!

 

我的oracle安装路径在F盘的app文件夹下,

首先找到F:\app\Administrator\product\11.1.0\db_1\NETWORK\ADMIN下的listener.ora和tnsnames.ora这两个文件,用记事本打开就可以

 

用下面的这些代码替换listener.ora中原有的代码

注:路径要是自己的安装路径

# listener.ora Network Configuration File: F:\app\Administrator\product\11.1.0\db_1\network\admin\listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = F:\app\Administrator\product\11.1.0\db_1)
      (PROGRAM = extproc)
    )
     (SID_DESC =
      (GLOBAL_DBNAME = orcl)
      (ORACLE_HOME = F:\app\Administrator\product\11.1.0\db_1)
      (SID_NAME = orcl)
    )
 
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    )
  )

 

 

 

 

# tnsnames.ora Network Configuration File: F:\app\Administrator\product\11.1.0\db_1\NETWORK\ADMIN\tnsnames.ora
# Generated by Oracle configuration tools.

ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )

EXTPROC_CONNECTION_DATA =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
    )
    (CONNECT_DATA =
      (SID = PLSExtProc)
      (PRESENTATION = RO)
    )
  )

 

 

 用下面的这些代码替换tnsnames.ora 中原有的代码

 

 

# tnsnames.ora Network Configuration File: F:\app\Administrator\product\11.1.0\db_1\NETWORK\ADMIN\tnsnames.ora
# Generated by Oracle configuration tools.

ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )

EXTPROC_CONNECTION_DATA =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
    )
    (CONNECT_DATA =
      (SID = PLSExtProc)
      (PRESENTATION = RO)
    )
  )

替换完成之后重启oracle数据库服务就可以了