plsql直接连接远程数据库_mysql切换数据库命令

2022-09-27 11:26:30 浏览数 (1)

大家好,又见面了,我是你们的朋友全栈君。

作者专注于Java、架构、Linux、小程序、爬虫、自动化等技术。 工作期间含泪整理出一些资料,微信搜索【程序员高手之路】,回复 【java】【黑客】【爬虫】【小程序】【面试】等关键字免费获取资料。


前言

先赞后看,此生必赚!

每次安装以后,都会出现使用plsql连接不上的问题!多次重启电脑、重装系统的磨人经历之后,

有木有想说句 TMD 平复一下心情?

先别骂!今天看到这篇文章算是你我之幸!希望能帮助广大技术人员减少一些时间,顺利进行连接!

注:也可以用plsql连接远程数据库(只要有networkadmintnsnames.ora就行)。

首先下载64位以及32位轻量级客户端(注意版本的对应,我用的是11g的和11.2的客户端):

以下步骤请自行更改路径,不然,出错了别怪我哦:

step1 复制network文件

安装到某路径下,安装步骤很简单,网上可以搜到!

客户端随便解压到一个路径,我的是放在D:appshuhaoinstantclient_11_2了。

然后把D:appshuhaoproduct11.2.0dbhome_1里面的整个network文件夹复制,

粘贴到客户端文件夹D:appshuhaoinstantclient_11_2下面,如下图所示:


step2 修改配置文件

2.1 修改数据库文件

D:appshuhaoproduct11.2.0dbhome_1NETWORKADMINlistener.ora文件内容,添加一个SID_DESC:

代码语言:javascript复制
# listener.ora Network Configuration File: D:appshuhaoproduct.2.0dbhome_1networkadminlistener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = CLRExtProc)
      (ORACLE_HOME = D:appshuhaoproduct.2.0dbhome_1)
      (PROGRAM = extproc)
      (ENVS = "EXTPROC_DLLS=ONLY:D:appshuhaoproduct.2.0dbhome_1binoraclr11.dll")
    )
#下面的SID_DESC是新增加的内容,注意修改ORACLE_HOME路径
    (SID_DESC =
      (SID_NAME = orcl)
      (ORACLE_HOME = D:appshuhaoproduct.2.0dbhome_1)
      (GLOBAL_DBNAME = orcl)
    )
  )

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

ADR_BASE_LISTENER = D:appshuhao

2.2 修改数据库文件

D:appshuhaoproduct11.2.0dbhome_1NETWORKADMINtnsnames.ora文件内容,源文件没有做改动:

代码语言:javascript复制
# tnsnames.ora Network Configuration File: D:appshuhaoproduct.2.0dbhome_1networkadmintnsnames.ora
# Generated by Oracle configuration tools.

ORACLR_CONNECTION_DATA =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = orcl)
    )
  )

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

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

2.3 修改客户端文件

D:appshuhaoinstantclient_11_2networkadmintnsnames.ora文件内容:

代码语言:javascript复制
# tnsnames.ora Network Configuration File: D:appshuhaoproduct.2.0dbhome_1networkadmintnsnames.ora
# Generated by Oracle configuration tools.

ORACLR_CONNECTION_DATA =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = orcl)
    )
  )

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

ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )
#新增 @ 标识符,用于区分本地与远程oracle
ORCL@192.168.0.164 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.164)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )

step3 配置OCI

不登录plsql,直接按Cancel,进入后在Tools—>Preferences—->Connection中配置OCI为32位客户端的OCI

D:appshuhaoinstantclient_11_2oci.dll

step4 环境变量配置

添加前2个系统变量:

1. 变量名:TNS_ADMIN

变量值:D:appshuhaoinstantclient_11_2networkadmin

2. 变量名:NLS_LANG

变量值:SIMPLIFIED CHINESE_CHINA.ZHS16GBK

3. Path中配置加入:

D:appshuhaoproduct11.2.0dbhome_1BIN;D:appshuhaoinstantclient_11_2;

step5 重启电脑(有时候不需要重启)

启动服务与监听,这个就不需要描述了。

step6 登录plsql!!!

当看到Database下拉框中有本地的ORCL以及远程的ORCL@192.168.0.164就算成功了!!!

OK, GAME OVER !

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/176038.html原文链接:https://javaforall.cn

0 人点赞