How to install Oracle SQLPlus and Oracle Client in MAC OS


The How To has been extracted from the following link:

I just skipped some text and modified some paths to adapt it to oracle client release.


1. Download the files from the Oracle Site

Be sure to grab the following two files:

  • Instant Client Package – Basic
  • Instant Client Package – SQL*Plus

2. Extract the files and create the proper folder structure.

Open a Terminal window and unzip the downloaded files.

$ unzip -qq

$ unzip -qq

Note: The -qq flag will tell the unzip utility to run in quieter mode, preventing any output from being displayed on the screen.

By default, the archive will extract all these files to a single directory. Instead, we’ll create a nicely structured directory to keep these files in your user Applications folder.

$ mkdir -p /Applications/oracle/product/instantclient_64/

$ mkdir -p /Applications/oracle/product/instantclient_64/

$ mkdir -p /Applications/oracle/product/instantclient_64/

$ mkdir -p /Applications/oracle/product/instantclient_64/

$ mkdir -p /Applications/oracle/product/instantclient_64/

$ mkdir -p /Applications/oracle/product/instantclient_64/

Next, move the files over to these directories as follows:

$ cd instantclient_11_2

$ mv ojdbc* /Applications/oracle/product/instantclient_64/

$ mv x*.jar /Applications/oracle/product/instantclient_64/

$ mv glogin.sql /Applications/oracle/product/instantclient_64/

$ mv *dylib* /Applications/oracle/product/instantclient_64/

$ mv *README /Applications/oracle/product/instantclient_64/

$ mv * /Applications/oracle/product/instantclient_64/

3. Create a proper tnsnames.ora file to define proper connection strings

Copy or create a tnsnames.ora file to /Applications/oracle/product/instantclient_64/


Create the tnsnames.ora file with the vi editor, paste the following lines and save it.











    )  )

(You can better ask to a DBA to review the content of this file and ask her to provide you with a proper test connection)

4. Set up environment variables

Edit or create a file .bash_profile

$ cd /Users/UserName

$ vi ~/.bash_profile

if you haven’t created a .bash_profile before the file will be empty, otherwise just add the following lines to the end of the existing file.

export ORACLE_HOME=/Applications/oracle/product/instantclient_64/



To load this profile, run the following command:

$ source ~/.bash_profile

Assuming you have set up your tnsnames.ora file correctly, you should now be able to connect one of the databases as follows:

5. Start using SQLPlus

$ sqlplus username/password@database

6. Did you enjoy? That’s all folks.



Fixing command history for using SQLPlus line edition with arrow keys

If you have used the command-line SQLPlus in a Windows environment, you will probably be used to using the command history to execute previous SQL statements using the arrow keys. One thing you’ll notice in SQLPlus for the Mac is that this doesn’t work by default, if you hit the up key you’ll see a strange character sequence ^[[A rather than the previous command. Let’s go ahead and fix this now.

To do this, you’ll need to use rlwrap. You could download this from source and build it yourself, but I find it much easier to use the fantastic brew package manager for Mac OS X. Head over to and follow the instructions to install and set up Homebrew (it’s very easy). With Homebrew installed, you can now easily install rlwrap on your system with one command:

$ ruby -e “$(curl -fsSL”

$ brew install rlwrap

The final thing you need to do is tell your system to use rlwrap whenever you use SQL*Plus. To do that, you’ll need to edit your .bash_profile file again.

$ vi ~/.bash_profile

Add the following line to the end of the file.

alias sqlplus=’rlwrap sqlplus’

Now reload the .bash_profile:

$ source ~/.bash_profile

Now, when you launch SQL*Plus and try to use the arrow keys to access previous commands, it will work.


27 thoughts on “How to install Oracle SQLPlus and Oracle Client in MAC OS

  1. Iulian

    Which one is ~/.bash_profilesource file? Because when i executed this line “source ~/.bash_profilesource ~/.bash_profile”, this error occurred: “-bash: /Users/macbook/.bash_profilesource: No such file or directory”. Thanks!

  2. Alex

    Hi, I done everything in the tutorial but the last part (5) $ sqlplus username/password@database says sqlplus command not found. Can you help me please?

  3. Casper

    Thanks for this. It was very helpful. I ran into one problem (“ORA-21561: OID generation failed”, which also appeared as “ORA-12162: TNS:net service name is incorrectly specified”. I solved it by typing “hostname” at the command line and adding the result to my /etc/hosts file. The new line looks something like this: “ local_mac_name”.

    1. Ave

      Hi Could you please post an example of how you did this? I am new in this and don’t really understand how you added the result to the directory above thank you!

  4. Pingback: Installing Oracle Instant Client for Mac OSX | Ajitabh Pandey.Info

    1. tomeumir Post author

      Check the environment variables that you have set in step 4. You can type the following commands in a terminal window:

      Tomeus-MBA-2:~ tomeu.mir$ echo $ORACLE_HOME
      Tomeus-MBA-2:~ tomeu.mir$ echo $PATH
      Tomeus-MBA-2:~ tomeu.mir$ echo $DYLD_LIBRARY_PATH

      If any of the echo commands returns you blank, then for sure that you did not update properly the .bash_profile. Else crosscheck that the paths that I marked in bold just above are the same ones where you have done the installation.

  5. Pingback: oracle client mac os X install | tkwordpresscomblog

  6. rai

    Thanks a lot, clean and clear steps, set it up in no time 🙂

    export ORACLE_HOME=”/Applications/oracle/product/instantclient_64/″
    export ORACLE_HOME=/Applications/oracle/product/instantclient_64/

  7. Josh

    Hi there,
    Thanks for the instructions! I was super excited for this tutorial…however, I’m getting this error when running sqlplus:

    dyld: Library not loaded: /ade/dosulliv_sqlplus_mac/oracle/sqlplus/lib/libsqlplus.dylib
    Referenced from: /usr/local/etc/Oracle/instantclient_64/
    Reason: image not found

    It looks like the dynamic library has a path hardcoded from someone’s system? I followed the instructions to a T. The only thing I can think of is perhaps I didn’t grab the correct downloaded files from Oracle.

  8. Bill

    Helpful article! Appreciate seeing the complete set of instructions to download and install.
    One change I had to make when editing ~/.bash_profile was:

    — original —
    export ORACLE_HOME=”/Applications/oracle/product/instantclient_64/″

    — my modification (quotes removed) —
    export ORACLE_HOME=/Applications/oracle/product/instantclient_64/

    Scrolling up in the comments, I see another poster ran into this issue. FYI. All that aside, this article was on target with getting SQL*Plus onto my mac!

  9. Chirag

    what is the username and password…
    also there is an error “ORA-12162: TNS:net service name is incorrectly specified”
    how to resolve it
    please help….

    1. tomeumir Post author

      Username and Password refers to your Oracle user.
      About the error: review your tnsnames.ora configuration file. The database specified when you try to login must fit with the configured MYBD in such a file.
      Send me yout tnsnames.ora file if you don’t get it by email.
      I hope it helps,

  10. Pingback: Data Virtualizer » SQL*PLus on Mac

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s