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用戶 oraclelinux

useradd oracle
passwd oracle
連續兩次輸入密碼,默認oracle的目錄是/home/oracle
切換到oracle用戶,目錄天然在/home/oracle
su - oracle 

  3. 上傳解壓  unzip解壓四個會解壓到一個文件夾中,例如:instantclient_12_1sql

  4. 修改環境變量bash

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

  五、新建tnsnames.rsa文件oracle

#新建文件夾
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. 驗證spa

sqlplus username/password@ip:port/service_name
sqlplus username/password@orcl
相關文章
相關標籤/搜索