好方式安装sqlplus
# install on MacOS
brew tap InstantClientTap/instantclient
cp ~/Download/instantclient*.zip /usr/local/Homebrew/Library/Taps/instantclienttap/homebrew-instantclient
brew install instantclient-basic
brew install instantclient-sqlplus
brew install instantclient-tools
sqlplus链接远程Oracle
sqlplus ZZL/zzl@localhost:1521/xe
下面的方式创建,使用时会有没有证书提示
1、下载包
http://download.oracle.com/otn/mac/instantclient/11203/instantclient-basic-macos.x64-11.2.0.3.0.zip
http://download.oracle.com/otn/mac/instantclient/11203/instantclient-sqlplus-macos.x64-11.2.0.3.0.zip
http://download.oracle.com/otn/mac/instantclient/11203/instantclient-sdk-macos.x64-11.2.0.3.0.zip
2、命令行操作
a) cd Downloads
unzip -qq instantclient-sqlplus-macos.x64-11.2.0.3.0.zip
unzip -qq instantclient-basic-macos.x64-11.2.0.3.0.zip
unzip -qq instantclient-sdk-macos.x64-11.2.0.3.0.zip
mkdir -p /Applications/oracle/product/instantclient_64/11.2.0.3.0/bin
mkdir -p /Applications/oracle/product/instantclient_64/11.2.0.3.0/lib
mkdir -p /Applications/oracle/product/instantclient_64/11.2.0.3.0/jdbc/lib
mkdir -p /Applications/oracle/product/instantclient_64/11.2.0.3.0/rdbms/jlib
mkdir -p /Applications/oracle/product/instantclient_64/11.2.0.3.0/sqlplus/admin
b) cd instantclient_11_2
mv ojdbc* /Applications/oracle/product/instantclient_64/11.2.0.3.0/jdbc/lib/
mv x*.jar /Applications/oracle/product/instantclient_64/11.2.0.3.0/rdbms/jlib/
mv glogin.sql /Applications/oracle/product/instantclient_64/11.2.0.3.0/sqlplus/admin/
mv *dylib* /Applications/oracle/product/instantclient_64/11.2.0.3.0/lib/
mv sdk /Applications/oracle/product/instantclient_64/11.2.0.3.0/lib/
mv *README /Applications/oracle/product/instantclient_64/11.2.0.3.0/
mv * /Applications/oracle/product/instantclient_64/11.2.0.3.0/bin/
c) 最后设置Oracle InstantClient的运行环境参数,运行命令:vim ~/.bash_profile,贴入以下内容:
export ORACLE_BASE=/Applications/oracle
export ORACLE_HOME=$ORACLE_BASE/product/instantclient_64/11.2.0.3.0
export PATH=$ORACLE_HOME/bin:$PATH
export DYLD_LIBRARY_PATH=$ORACLE_HOME/lib
export TNS_ADMIN=$ORACLE_BASE/admin/network
export NLS_LANG="AMERICAN_AMERICA.UTF8"
配置完之后一定要重新加载下配置文件:
保存后的环境变量不会立即生效,需要执行 source ~/.bash_profile
d) 最后运行以下脚本安装ruby的oracle接口即可。
ln -s /Applications/oracle/product/instantclient_64/11.2.0.3.0/lib/libclntsh.dylib.11.1 /Applications/oracle/product/instantclient_64/11.2.0.3.0/lib/libclntsh.dylib
gem install ruby-oci8