Saturday, August 11, 2012

How to Install Oracle SQL Plus on Ubuntu 12.04

On my day to day work I have to deal with Oracle a lot! and since I am trying to use Ubuntu as my working environment I had to install a bunch of things one of them is SQL Plus. I like command line a lot and SQL plus is the best tool for Oracle so I had to have it.

The process is not so complicated. So let's start first you need to go to the Database Instant Client page and download the one specific to your platform. This post is for 32 bit so you have to download the Instant Client Downloads for Linux x86 one. It should be the same for the 54 bit though. From there you need to download these 2 rpm files:
  • Instant Client Package - Basic: All files required to run OCI, OCCI, and JDBC-OCI applications
  • Instant Client Package - SQL*Plus: Additional libraries and executable for running SQL*Plus with Instant Client
If you want, you can download the SDK :
  • Instant Client Package - SDK: Additional header files and an example makefile for developing Oracle applications with Instant Client
Since these are rpm files we need to convert them to deb, in order to that we need to install the alien utility
sudo apt-get install alien

Once that is done, go to the folder where the rpm files are located and execute the following
alien -i oracle-instantclient-basic*.rpm
alien -i oracle-instantclient-sqlplus*.rpm
alien -i oracle-instantclient-devel*.rpm

These commands will convert the rpm files on the fly and install them. Now you can test it by just typing sqlplus on the command line. For sure it will complain about a couple of things. One of them maybe about a missing libaio.so.1 . This one is easy, we just need to install it a simple
sudo apt-get install libaio1
The next error might be about missing libraries like libsqlplus.so. The libraries are there but SQL Plus can't find them. We need to add them to our PATH this is easy as well. We just need to create an oracle.conf file inside /etc/ld.so.conf.d/ so lets do that. I use vi because I like it, but you can use whichever editor you want to create the file.
sudo vi /etc/ld.so.conf.d/oracle.conf
then we add this:
/usr/lib/oracle/11.2/client/lib/
Notice that in my path I have 11.2 be careful with this. You can navigate and check that the path is correct for yours. 11.2 is the version we are installing. At the time of this post 11.2 was the latest one. Once you save the file we need to update the configuration by running:
sudo ldconfig

Now you should be ready to connect using:
sqlplus username/password@//dbhost:1521/SID

If you have problems with the SDK, you can check this post.
Hope it helps someone and happy coding!

14 comments:

  1. nice post. bt i can't login. plz help.
    What is the username and password?

    ReplyDelete
  2. How do you create a new user and password to log in using sqlplus ?

    ReplyDelete
  3. At the beginning you have to log in using the sys user something like this:
    sqlpus sys/[youpassword] as sysdba

    then create a user
    create user testuser identified by "password";

    then you can do:
    sqlplus testuser/password

    ReplyDelete
  4. Hi,
    it is a nice post, thank you.

    I did all the steps you described, and no error message have been diplayed. But at the final step:
    " sqlplus username/password@//dbhost:1521/SID "

    the terminal displays that:
    sqlplus: error while loading shared libraries: libsqlplus.so: cannot open shared object file: No such file or directory

    Have you any idea about how to fix this?
    Thanks

    ReplyDelete
    Replies
    1. It's probably because the LD_LIBRARY_PATH was not set up. See the part about creating an oracle.conf file in the /etc/ld.so.conf.d directory. That should fix things for you.

      Delete
    2. in order to solve this problem, type this comand sudo apt-get install libaio1 works fine to me.

      Delete
  5. Very nice set of instructions. Thx!

    ReplyDelete
  6. Hi, very helpful, but Can u tell me how to connect to the HR schema so that I can excute my queries on the already created tables in HR schema.
    Thank you.

    ReplyDelete
  7. Great job Marcelo...
    Working perfectly 32/64 bit Ubuntu and 12.1 oracle instant client too...
    Just changing the path to the libraries (/usr/lib/oracle/12.1/client64/lib)

    Thanks
    Norberto.cintio@gmail.com

    ReplyDelete
  8. Hi, nice method of installation of Sql Plus on Ubuntu Os.I extremely helped in installing Sql Plus in Os.Thanks....

    -Aparna
    Theosoft

    ReplyDelete
  9. Nice Post Bro, You solved my Problem. Really Very Helpful Post thanks a lot
    C Projects

    ReplyDelete