Velvet Star Monitor

Standout celebrity highlights with iconic style.

general

How to install SqlPlus?

Writer Olivia Zamora

I tried installing sqlplus by following the instruction from here. I'm still getting :

sqlplus: command not found

when I do sqlplus from my terminal.

I'm an novice in Ubuntu and I use Ubuntu 12.04.

1

5 Answers

First of all you need to download Instant Client Downloads. Install alien package so you can install rpm packages by typing following command in terminal.

sudo apt-get install alien

Once that is done, go to the folder where the rpm files are located and execute the following:

sudo alien -i oracle-instantclient*-basic*.rpm
sudo alien -i oracle-instantclient*-sqlplus*.rpm
sudo alien -i oracle-instantclient*-devel*.rpm

You need to install libaio.so. Type following command to do it:

sudo apt-get install libaio1

Create Oracle configuration file:

sudo sensible-editor /etc/ld.so.conf.d/oracle.conf

Put this line in that file:

/usr/lib/oracle/<your version>/client/lib/ 

Note - for 64-bit installations, the path will be:

/usr/lib/oracle/<your version>/client64/lib/ 

Update the configuration by running following command:

sudo ldconfig

Try to connect using:

sqlplus username/password@//dbhost:1521/SID

or:

sqlplus testuser/password

Note that if you installed the 64-bit version, the client is called sqlplus64.

5

The alien thing didn't work because of:

Error: cannot open Name index using db5 - Permission denied (13)

Fortunately, there is a more native solution:

Download the zip files from Oracle, you need

  • Basic Package (ZIP) (or Basic Light Package (ZIP))
  • SQL*Plus Package (ZIP)

The archives extract into the same root folder. Put that folder where you put program files (e.g. /usr/share or $HOME/bin).

Then create a script that runs the executable after setting the LD_LIBRARY_PATH variable, so that libraries are found:

#!/bin/bash
CLIENTDIR=/usr/share/instantclient_12_2 # <------- adjust this to the path you use
export LD_LIBRARY_PATH="$CLIENTDIR"
"$CLIENTDIR"/sqlplus "$@"

Call it sqlplus, make it executable (chmod 755 sqlplus) and put it into a directory on your PATH (e.g. /usr/bin/), so that bash finds it.

That's it, now you can run sqlplus like:

sqlplus user/password@host:port/service

If it gives you:

error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory

you need to install the missing library with sudo apt-get install libaio1

I think this link would help. It is pretty descriptive. Make sure you follow all the steps. Still if you have any problems, don't hesitate to comment.

4

Of course the correct installation is from official packages like above (download Instant Client Downloads), but you can get a full working sqlplus just by copying these files (you can found it in any computer with oracle client installed), and some msb are optitional:

./sqlplus
./sqlplus/mesg
./sqlplus/mesg/sp1zhs.msb
./sqlplus/mesg/sp2zhs.msb
./sqlplus/mesg/sp2ptb.msb
./sqlplus/mesg/sp2us.msb
./sqlplus/mesg/sp1us.msb
./sqlplus/mesg/sp1ptb.msb
./sqlplus/mesg/cpyja.msb
./sqlplus/mesg/sp1ja.msb
./sqlplus/mesg/cpyus.msb
./sqlplus/mesg/cpyzhs.msb
./sqlplus/mesg/cpyptb.msb
./sqlplus/mesg/sp2ja.msb
./sqlplus/sqlplus
./README
./lib
./lib/libaio.so.1
./lib/libclntsh.so.11.1
./lib/libsqlplus.so
./lib/libnnz11.so
./lib/libociei.so

As aditional dependency, I did include libaio.so - it can be installed with sudo apt-get install libaio1

So, a sample use can be:

cd <PATH_OF_FILES>
ORACLE_HOME=$PWD LD_LIBRARY_PATH=$PWD/lib ./sqlplus/sqlplus user/pw@server:PORT/

Just as an addendum to @Ketan Patel's great answer:

This simple script, kept together with downloaded rpm files, autpmates the process for futher installs:

#!/usr/bin/env sh
#
CURRDIR="$(pwd)";
cd $(dirname "${0}");
# Tools and dependencies:
sudo apt-get update
sudo apt-get install alien libaio1
# Oracle Packages:
echo "Installing instantclient-basic..."
sudo alien -i oracle-instantclient*-basic*.rpm
echo "Installing instantclient-sqlplus..."
sudo alien -i oracle-instantclient*-sqlplus*.rpm
echo "Installing instantclient-devel..."
sudo alien -i oracle-instantclient*-devel*.rpm
echo "Configuring LD path..."
# LD config:
echo /usr/lib/oracle/*/client64/lib \ | sort -V \ | tail -n 1 \ | sudo tee /etc/ld.so.conf.d/oracle.conf \
;
sudo ldconfig
cd "${CURRDIR}"
echo "DONE!!";

NOTE: It installs libaio1 which is the libaio's name at least in Ubuntu (and I think in Debian too). Other distributions may need to adjust this package name to "libaio" or whatever the corresponding package name would be.

Edit: Here it is an ehanced version with readline wrapping (credists for this post):

#!/usr/bin/env sh
#
CURRDIR="$(pwd)";
cd $(dirname "${0}");
# Tools and dependencies:
sudo apt-get update
sudo apt-get install alien libaio1 rlwrap
# Oracle Packages:
echo "Installing instantclient-basic..."
sudo alien -i oracle-instantclient*-basic*.rpm
echo "Installing instantclient-sqlplus..."
sudo alien -i oracle-instantclient*-sqlplus*.rpm
echo "Installing instantclient-devel..."
sudo alien -i oracle-instantclient*-devel*.rpm
# LD config:
echo "Configuring LD path..."
echo /usr/lib/oracle/*/client64/lib \ | sort -V \ | tail -n 1 \ | sudo tee /etc/ld.so.conf.d/oracle.conf \
;
sudo ldconfig
# Readline wrapping:
echo "Configuring readline wrapping..."
echo "WARNING: You need to manually execute this command or re-read /etc/profile"
echo "if you want readline wrapped 'sqlplus' alias to work in current session".
(cat | sudo tee /etc/profile.d/sqlplus_rlwrap.sh) <<!EOF
alias sqlplus="rlwrap -i -f ~/.sqlplus_history -H ~/.sqlplus_history -s 30000 sqlplus64"
!EOF
touch ~/.sqlplus_history
cd "${CURRDIR}"
echo "DONE!!";

It's still Oracle, but at least it makes the pain a little bit more bearable...

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy