码迷,mamicode.com
首页 > 其他好文 > 详细

navicat连接客户端报错

时间:2019-05-14 14:53:21      阅读:145      评论:0      收藏:0      [点我收藏+]

标签:dia   ble   class   red   name   mysq   window   lin   lap   

怎么感觉oracle和sql server是一个货色。装个服务得装半天,还是mysql好,一下子就好了!下面有一个在centos7上面安装oracle11g的详细步骤,感觉找不到比这个更详细的了吧!

centos7安装详细步   :https://www.cnblogs.com/VoiceOfDreams/p/8308601.html

安装数据库之后在使用客户端连接数据库的时候总是报如下错误:

ORA-12514: TNS:listener does not currently know of service requested in connect

然后百度+谷歌,解决办法说是修改listener.ora文件,在文件中添加如下内容:【下面文件中标红的表示添加的内容】

[oracle@oracle ~]$ cd /data/oracle/product/11.2.0/db_1/network/admin/
[oracle@oracle admin]$ cat listener.ora 
# listener.ora Network Configuration File: /data/oracle/product/11.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.9.8.201)(PORT = 1521))
    )


   (SID_DESC =
      (GLOBAL_DBNAME = orcl)
      (ORACLE_HOME = /data/oracle/product/11.2.0/db_1)
      (SID_NAME = orcl)
    )
  )

ADR_BASE_LISTENER = /data/oracle

添加完之后重新启动监听器,连接的时候报如下错误:

ERROR:
ORA-12504: TNS:listener was not given the SERVICE_NAME in CONNECT_DATA

又去百度+谷歌,大部分答案都是说tnsnames.ora中service_name写成了server_name等,可是tnsnames.ora这个文件是oracle服务器自己生成的啊。

这时候查看监听器状态会有如下提示:

[oracle@oracle ~]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 14-MAY-2019 21:35:17

Copyright (c) 1991, 2009, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date                14-MAY-2019 19:16:38
Uptime                    0 days 2 hr. 18 min. 39 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /data/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File         /data/oracle/diag/tnslsnr/oracle/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.9.8.201)(PORT=1521)))
The listener supports no services                                 #这里提示没有服务
The command completed successfully

最后的解决办法,重启监听器,重启服务器。

[oracle@oracle admin]$ sqlplus /nolog

SQL*Plus: Release 11.2.0.1.0 Production on Tue May 14 21:57:46 2019

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

SQL> connect sys / as sysdba
Enter password: 
Connected.
SQL> shutdown immediate                    #关闭oracle服务器
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup                               #启动oracle服务器
ORACLE instance started.

Total System Global Area  759943168 bytes
Fixed Size            2217224 bytes
Variable Size          507513592 bytes
Database Buffers      247463936 bytes
Redo Buffers            2748416 bytes
Database mounted.
Database opened.
SQL> 

查看监听器状态:

[oracle@oracle admin]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 14-MAY-2019 22:18:47

Copyright (c) 1991, 2009, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date                14-MAY-2019 19:16:38
Uptime                    0 days 3 hr. 2 min. 8 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /data/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File         /data/oracle/diag/tnslsnr/oracle/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.9.8.201)(PORT=1521)))
Services Summary...
Service "orcl" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orclXDB" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully

使用客户端连接oracle数据库:

[oracle@oracle admin]$ sqlplus scott/tiger@10.9.8.201/orcl

SQL*Plus: Release 11.2.0.1.0 Production on Tue May 14 22:19:21 2019

Copyright (c) 1982, 2009, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> 

客户端连接成功:

技术图片

 

更改oracle监听端口

oracle安装之后监听的本地的127.0.0.1这个ip,但是在window系统连接很显然不行的,更改上面提到的哪两个文件中的localhost为服务器的ip即可,然后重启监听器。

[oracle@oracle admin]$ cat listener.ora 
# listener.ora Network Configuration File: /data/oracle/product/11.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.9.8.201)(PORT = 1521))
    )


   (SID_DESC =
      (GLOBAL_DBNAME = orcl)
      (ORACLE_HOME = /data/oracle/product/11.2.0/db_1)
      (SID_NAME = orcl)
    )
  )

ADR_BASE_LISTENER = /data/oracle

[oracle@oracle admin]$ cat tnsnames.ora 
# tnsnames.ora Network Configuration File: /data/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

LISTENER_ORCL =
  (ADDRESS = (PROTOCOL = TCP)(HOST = 10.9.8.201)(PORT = 1521))


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

 

navicat连接客户端报错

标签:dia   ble   class   red   name   mysq   window   lin   lap   

原文地址:https://www.cnblogs.com/wxzhe/p/10861986.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!