下载安装包

首先到 Oracle 官网 下载 SQL Plus 相关包

安装

下载 rpm 包并上传至服务器后,直接使用命令安装

# yum -y install oracle-instantclient11.2-*

安装完成后还需要配置相应的环境变量

# echo "export ORACLE_HOME=/usr/lib/oracle/11.2/client64" >> ~/.bashrc
# echo "export TNS_ADMIN=$ORACLE_HOME" >> ~/.bashrc
# echo "export PATH=$PATH:$ORACLE_HOME/bin" >> ~/.bashrc
# echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib" >> ~/.bashrc
# source ~/.bashrc

配置 TNS 连接文件

# vim /usr/lib/oracle/11.2/client64/tnsnames.ora

内容如下:

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

ORCL_96 =
    (DESCRIPTION =
        (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.96)(PORT = 1521))
        (CONNECT_DATA =
            (SERVER = DEDICATED)
            (SERVICE_NAME = orcl)
        )
    )

保存配置文件后,即可使用 sqlplus 命令连接数据库

其中:scott为用户名,tiger为密码,ORCL_96是 tns 配置文件中数据库名。请按实际情况修改

# sqlplus scott/tiger@ORCL_96
SQL>

标题:CentOS 安装 Oracle SQLPlus
作者:akiya789
地址:https://little-star.love/articles/2020/04/17/1587093309344.html

添加新评论