How to install SQL * PLUS client in linux

你说的曾经没有我的故事 提交于 2019-11-30 00:11:16

Go to Oracle Linux x86-64 instant clients download page

Download the matching client

oracle-instantclient11.2-basic-11.2.0.2.0.x86_64.rpm
oracle-instantclient11.2-sqlplus-11.2.0.2.0.x86_64.rpm

Install

rpm -ivh oracle-instantclient11.2-basic-11.2.0.2.0.x86_64.rpm
rpm -ivh oracle-instantclient11.2-sqlplus-11.2.0.2.0.x86_64.rpm

Set environment variables in your ~/.bash_profile

ORACLE_HOME=/usr/lib/oracle/11.2/client64
PATH=$ORACLE_HOME/bin:$PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib
export ORACLE_HOME
export LD_LIBRARY_PATH
export PATH

Reload your .bash_profile by simply typing source ~/.bash_profile (suggested by jbass) or Log-out user and log-in again.

Now you're ready to use SQL*Plus and connect your server. Type in :

sqlplus "username/pass@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.2.1)(PORT=1521))(CONNECT_DATA=(SID=YOURSID)))"

The solution by @ChamaraKeragala is good, but it is unnecessary to logout/login. Instead type:

source ~/.bash_profile
Naresh

For everyone still getting the following error:

sqlplus command not found

The original post refers to a set of environment variables, the most important of which is ORACLE_HOME. This is the parent directory where the oracle binaries get installed.

Depending on what version of oracle you downloaded you'll have to change the ORACLE_HOME accordingly. For example, the original question's ORACLE_HOME was set to:

ORACLE_HOME=/usr/lib/oracle/11.2/client64

My version of Oracle happens to be 12.1, so my ORACLE_HOME is set to:

ORACLE_HOME=/usr/lib/oracle/12.1/client64 

If you are unsure of the version that you downloaded, you can:

  1. cd /usr/lib/oracle after the installation and find the version.
  2. Look at the RPM file oracle-instantclient12.1, where the bolded bits would refer to the version number.

There's a good blog post[1] on $subject. setup oracle client in ubuntu with minimum effort. Following are the main steps on how to step up the client. In my case, I was installing rpm files using alien package.

  1. Install alien and related packages

    sudo apt-get install alien

  2. Install oracle client packages using alien.

    sudo alien -i oracle-instantclient11.2-basic-11.2.0.3.0-1.x86_64.rpm

    sudo alien -i oracle-instantclient11.2-sqlplus-11.2.0.3.0-1.x86_64.rpm

In my opinion these two steps are the easiest way to install oracle client rpm's on your ubuntu system. (I'm not going to mention about export oracle specific variables as it's already clearly explained in above answers)

Hope it helps someone.

[1] http://pumuduruhunage.blogspot.com/2016/04/setup-oracle-sql-plus-client-on-aws.html

For any one who is using proxy, you'd need to add an extra line to the bash profile. At least this is what made it work for me. I'm using cntlm.

export no_proxy=

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!