navicat连接客户端报错
怎么感觉oracle和sql server是一个货色。装个服务得装半天,还是mysql好,一下子就好了!下面有一个在centos7上面安装oracle11g的详细步骤,感觉找不到比这个更详细的了吧!
centos7安装详细步 :https://www.cnblogs.com/VoiceOfDreams/p/8308601.html
navicat连接oracle
安装数据库之后在使用客户端连接数据库的时候总是报如下错误:
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) ) )
oracle的sys用户远程登录
SQL> show parameter pass NAME TYPE VALUE ------------------------------------ ---------------------- ------------------------------ remote_login_passwordfile string EXCLUSIVE SQL>
remote_login_passwordfile有3个取值,取值如下:
- none:不允许sysdba用户组成员远程登录访问数据库
- exclusive: 只允许口令文件用于本数据库,允许sysdba用户组成员远程登录访问数据库
- shared: 允许其他数据库使用该口令文件,允许sysdba用户组成员远程登录访问数据库。
这个值设置若是none,则需要通过以下语句设置为exclusive.
SQL> alter system set remote_login_passwordfile=exclusive scope=spfile;
System altered.
然后需要重新启动数据库。
以上完成之后,设置sys用户的密码:
SQL> alter user sys identified by 123456; User altered.
在navicat中填入对应的连接字段,点击测试,报如下错误:
这时候点击,高级选项,把角色选为sysdba,连接即可!