首先Oracle官網下載安裝包:
http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html
安裝解壓縮到/usr/local/oracle
mkdir /usr/local/oracle
unzip /usr/local/oracle/instantclient-basic-linux.x64-11.2.0.4.0.zip
unzip /usr/local/oracle/instantclient-sqlplus-linux.x64-11.2.0.4.0.zip
cd /usr/local/oracle/instantclient_11_2
mkdir -p network/admin
cd network/admin
新建tnsnames.ora文件
CM =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.12.11)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = cm)
)
)
添加環境變量
vi .bash_profile
export ORACLE_HOME=/usr/local/oracle/instantclient_11_2
export TNS_ADMIN=$ORACLE_HOME/network/admin
##export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
export LD_LIBRARY_PATH=$ORACLE_HOME
export PATH=$ORACLE_HOME:$PATH
執行環境變量
source .bash_profile
測試數據庫連接
sqlplus username/passwd@cm
本文參考
https://blog.csdn.net/andy_wcl/article/details/79470705