linux安装sqlplus客户端连接oracle

  1. 下载  在oracle官网搜索Instant Client Downloads,下载包名例子
instantclient-basic-linux.x64-12.1.0.2.0.zip
instantclient-jdbc-linux.x64-12.1.0.2.0.zip
instantclient-sqlplus-linux.x64-12.1.0.2.0.zip
instantclient-tools-linux.x64-12.1.0.2.0.zip

  2. 新建 linux用户 oracle

useradd oracle
passwd oracle
连续两次输入密码,默认oracle的目录是/home/oracle
切换到oracle用户,目录自然在/home/oracle
su - oracle 

  3. 上传解压  unzip解压四个会解压到一个文件夹中,例如:instantclient_12_1

  4. 修改环境变量

vi ~/.bash_profile 
#添加以下内容
export ORACLE_HOME=/home/oracle/instantclient_12_1
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME
export PATH=$PATH:$ORACLE_HOME
export TNS_ADMIN=$ORACLE_HOME/network/admin
export NLS_LANG=AMERICAN_AMERICA.UTF8
source ~/.bash_profile

  5、新建tnsnames.rsa文件

#新建文件夹
mkdir -p /home/oracle/instantclient_12_1/network/admin
cd /home/oracle/instantclient_12_1/network/admin
vi tnsnames.ora
#添加以下内容
orcl=
    (DESCRIPTION =
        (ADDRESS_LIST =
            (ADDRESS = (PROTOCOL = TCP)(HOST = 172.17.1.18)(PORT = 1521))
        )
        (CONNECT_DATA =
            (SERVICE_NAME = orcl)
        )
    )

  6. 验证

sqlplus username/password@ip:port/service_name
sqlplus username/password@orcl

 

转载于:https://www.cnblogs.com/ggblog/p/9084411.html

你可能感兴趣的:(linux安装sqlplus客户端连接oracle)