Sunday, July 14, 2013

How to install Oracle Instant Client 12c and Oracle SQL Plus on Ubuntu

So you want to use your Ubuntu distribution and connect to an Oracle database.
Here you can find the steps to install and configure the Oracle Instant Client on Ubuntu 12.04.

First of all you need to go to the following link and choose the Instant Client for your platform (in my case it is "Instant Client for Linux x86").

On the next web page select "Accept License Agreement" so you can download some rpm packets of the latest available Instant Client version (today is Version

Click on oracle-instantclient12.1-basic- (Instant Client Package - Basic: All files required to run OCI, OCCI, and JDBC-OCI applications), oracle-instantclient12.1-sqlplus- (Instant Client Package - SQL*Plus: Additional libraries and executable for running SQL*Plus with Instant Client) and oracle-instantclient12.1-devel- (Instant Client Package - SDK: Additional header files and an example makefile for developing Oracle applications with Instant Client).

To be available to download those rpm packets you have also to sign in into the Oracle website.

Next step is to install alien on your distribution.
From the man page "alien is a program that converts between Red Hat rpm, Debian deb, Stampede slp, Slackware tgz, and Solaris pkg file formats. If you want to use a package from another linux distribution than the one you have installed on your system, you can use alien to convert it to your preferred package format and install it."

ubuntu@ubuntu-VirtualBox:~$ sudo apt-get install alien
Then go to your download directory and list the available rpm packets.
ubuntu@ubuntu-VirtualBox:~$ cd Downloads/
ubuntu@ubuntu-VirtualBox:~/Downloads$ ls
Let's install all of them using alien command:
ubuntu@ubuntu-VirtualBox:~/Downloads$ sudo alien -i oracle-instantclient12.1-sqlplus-
    dpkg --no-force-overwrite -i oracle-instantclient12.1-sqlplus_12.
Selecting previously unselected package oracle-instantclient12.1-sqlplus.
(Reading database ... 142987 files and directories currently installed.)
Unpacking oracle-instantclient12.1-sqlplus (from oracle-instantclient12.1-sqlplus_12. ...
Setting up oracle-instantclient12.1-sqlplus ( ...
Now it's time for the Instant Client Basic Package:
ubuntu@ubuntu-VirtualBox:~/Downloads$ sudo alien -i oracle-instantclient12.1-basic-
    dpkg --no-force-overwrite -i oracle-instantclient12.1-basic_12.
Selecting previously unselected package oracle-instantclient12.1-basic.
(Reading database ... 143000 files and directories currently installed.)
Unpacking oracle-instantclient12.1-basic (from oracle-instantclient12.1-basic_12. ...
Setting up oracle-instantclient12.1-basic ( ...
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place
And finally it's time for Instant Client SDK Package:
ubuntu@ubuntu-VirtualBox:~/Downloads$ sudo alien -i oracle-instantclient12.1-devel-
    dpkg --no-force-overwrite -i oracle-instantclient12.1-devel_12.
Selecting previously unselected package oracle-instantclient12.1-devel.
(Reading database ... 143016 files and directories currently installed.)
Unpacking oracle-instantclient12.1-devel (from oracle-instantclient12.1-devel_12. ...
Setting up oracle-instantclient12.1-devel ( ...
Let's try to issue the sqlplus command
ubuntu@ubuntu-VirtualBox:~$ sqlplus / as sysdba
sqlplus: error while loading shared libraries: cannot open shared object file: No such file or directory
Ops.. it fails because of a missing shared object file: So install libaio1 using the usual apt-get command.
ubuntu@ubuntu-VirtualBox:~$ sudo apt-get install libaio1
Reading package lists... Done
Building dependency tree      
Reading state information... Done
The following NEW packages will be installed:
0 upgraded, 1 newly installed, 0 to remove and 608 not upgraded.
Need to get 6,648 B of archives.
After this operation, 53.2 kB of additional disk space will be used.
Get:1 precise/main libaio1 i386 0.3.109-2ubuntu1 [6,648 B]
Fetched 6,648 B in 0s (12.5 kB/s)
Selecting previously unselected package libaio1.
(Reading database ... 143067 files and directories currently installed.)
Unpacking libaio1 (from .../libaio1_0.3.109-2ubuntu1_i386.deb) ...
Setting up libaio1 (0.3.109-2ubuntu1) ...
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place
Let's try to run sqlplus again.
ubuntu@ubuntu-VirtualBox:~/Downloads$ sqlplus / as sysdba
sqlplus: error while loading shared libraries: cannot open shared object file: No such file or directory
sqlplus complains about missing libraries. You can solve creating/editing the oracle.conf file issuing the following command and simply adding a line (the path where were installed all the libraries of the Instant Client packages: /usr/lib/oracle/12.1/client/lib):
ubuntu@ubuntu-VirtualBox:~/Downloads$sudo vi /etc/
Now update the information of all the shared libraries on your system.
ubuntu@ubuntu-VirtualBox:~/Downloads$sudo ldconfig
Run sqlplus again... and as you can see it works...
ubuntu@ubuntu-VirtualBox:~$ sqlplus / as sysdba

SQL*Plus: Release Production on Sun Jul 14 20:01:37 2013

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

ORA-12162: TNS:net service name is incorrectly specified
... even if there's no database to connect to...
On the next post a new Oracle Database 12c will be finally available.

That's all.


Anonymous said...

Excelent work!!

Ashrith H Chinivar said...

I did exactly the same but at the end, it asks for username and password. Since no password is given during installation, WHAT is my username and password? Can I reset password using commandline? HELP please!

arok jaise said...

what is the default user name and password pleaseee

Avinash pal said...

please help me default username & password is not working for me its urgent
help me