37

How to install Oracle Instant Client Version 12.1.0.2 (64-bit) on a Mac (OS X 10.11.5)

I have downloaded version 12.1.0.2 (64-bit) version and unzipped the file.

I now have the following files under /downloads/instantclient:

libclntsh.dylib.12.1
libclntshcore.dylib.12.1
libnnz12.dylib
libocci.dylib.12.1
libociei.dylib
libocijdbc12.dylib
libons.dylib
liboramysql12.dylib
ojdbc6.jar
ojdbc7.jar
uidrvci
xstreams.jar
adrci
BASIC_README
genezi

I don't have the slightest idea how to go from this to a working version of Instant Client so I can connect to a db from the CLI. The instructions on Oracles website seem to be overly complicated.

I have found a few blogs detailing the installation method, but they all seem to be from previous version of Instant Client. Out of desperation, I downloaded a previous version of Instant Client, but still seemed to be missing files referred to in the tutorial.

Does anyone know how I can get Oracle Instant Client on my Mac?

wolφi
  • 8,091
  • 2
  • 35
  • 64
Ben
  • 519
  • 1
  • 7
  • 14

4 Answers4

39

HomeBrew saved me. I did not figure out the environment path.

Per referenced blog this Answer (see bottom) was originated from:

(Update 10/06/2020: Step 1 is no longer necessary, just run the brew commands!)

1. Download the two files below from http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html.

This is necessary because of Oracle licenses.

instantclient-basic-macos.x64–11.2.0.4.0.zip and instantclient-sqlplus-macos.x64–11.2.0.4.0.zip

Put the files in ~/Library/Caches/Homebrew


PS:

in the latest versions of HomeBrew replace the above location ~/Library/Caches/HomeBrew with ~/Library/Caches/HomeBrew/downloads.

And also rename the downloaded files with the names suggested by HomeBrew.

Thanks to @manuka_m


2. Next run the following commands

$ brew tap InstantClientTap/instantclient

$ brew install instantclient-basic

$ brew install instantclient-sqlplus

Originated from Joost van Wollingen's doc

bbrame
  • 18,031
  • 10
  • 35
  • 52
dengApro
  • 3,848
  • 2
  • 27
  • 41
  • 1
    In the terminal @SunishthaSingh . Homebrew is Mac related – dengApro Jun 04 '18 at 03:05
  • 1
    I don't have ~/Library/Caches/Homebrew in my Mac. Where is it? – Sam May 31 '19 at 08:09
  • 3
    Please note in the latest versions of HomeBrew replace the above location `~/Library/Caches/HomeBrew` with `~/Library/Caches/HomeBrew/downloads`. And also rename the downloaded files with the names suggested by HomeBrew. – manuka_m Sep 02 '19 at 11:22
  • 2
    "With the names suggested by HomeBrew" -- what does this mean? Where would I see such suggestions? – trevorsky Mar 02 '20 at 16:18
  • Sorry, not maintained. I am not a DB developer now. – dengApro Mar 21 '20 at 09:24
  • 2
    See [Janusz's answer](https://stackoverflow.com/questions/37711482/how-to-install-oracle-instant-client-on-a-mac/58815844#58815844). Joost updated [the instructions](https://vanwollingen.nl/install-oracle-instant-client-and-sqlplus-using-homebrew-a233ce224bf) in 2020 - the manual download step is no longer needed. You only need the `brew tap` and `brew install` steps. – Christian Long Apr 29 '21 at 22:57
24

There are multiple files available for download. From the files you listed you have only downloaded and unzipped the 'basic' package.

To run the CLI (by which I assume you mean SQL*Plus) you need that package as well - the fourth in the list, titled "Instant Client Package - SQL*Plus: Additional libraries and executable for running SQL*Plus with Instant Client".

The packages are arranged such that if you unzip all the ones you need from the same place they all put their files in the same directory. Unfortunately that doesn't quite work if you use Safari and have it set to open certain downloaded files; each zip file is expanded into a separate folder, with incremented names. And it deletes the zip files afterwards.

You can either disable that automatic unzipping and do it manually, or copy the files from the individual folders into a common one.

You may also need to create a symbolic link for the main client library; from inside that folder (in Terminal) you would do:

ln -s libclntsh.dylib.12.1 libclntsh.dylib

You can put that combined folder anywhere you like. You then need to add the full path to that folder to your PATH and environment variable - you can add that to your .bash_profile so you don't need to do it manually.

Once you've done that you can execute sqlplus from anywhere.

So to summarise:

  1. If you're using Safari, disable automatic opening of the zip files; from Safari->Preferences->General untick the 'Open "safe" files after downloading' checkbox.

  2. Download instantclient-basic-macos.x64-12.1.0.2.0.zip and instantclient-sqlplus-macos.x64-12.1.0.2.0.zip

  3. In Terminal go to your Downloads directory.

  4. Unzip both files:

    MacBook:Downloads alex$ unzip instantclient-basic-macos.x64-12.1.0.2.0.zip
    Archive:  instantclient-basic-macos.x64-12.1.0.2.0.zip
      inflating: instantclient_12_1/BASIC_README  
      inflating: instantclient_12_1/adrci  
      inflating: instantclient_12_1/genezi  
      inflating: instantclient_12_1/libclntsh.dylib.12.1  
      inflating: instantclient_12_1/libclntshcore.dylib.12.1  
      inflating: instantclient_12_1/libnnz12.dylib  
      inflating: instantclient_12_1/libocci.dylib.12.1  
      inflating: instantclient_12_1/libociei.dylib  
      inflating: instantclient_12_1/libocijdbc12.dylib  
      inflating: instantclient_12_1/libons.dylib  
      inflating: instantclient_12_1/liboramysql12.dylib  
      inflating: instantclient_12_1/ojdbc6.jar  
      inflating: instantclient_12_1/ojdbc7.jar  
      inflating: instantclient_12_1/uidrvci  
      inflating: instantclient_12_1/xstreams.jar  
    MacBook:Downloads alex$ unzip instantclient-sqlplus-macos.x64-12.1.0.2.0.zip
    Archive:  instantclient-sqlplus-macos.x64-12.1.0.2.0.zip
      inflating: instantclient_12_1/SQLPLUS_README  
      inflating: instantclient_12_1/glogin.sql  
      inflating: instantclient_12_1/libsqlplus.dylib  
      inflating: instantclient_12_1/libsqlplusic.dylib  
      inflating: instantclient_12_1/sqlplus  
    
  5. Optionally rename and/or move the instantclient_12_1 directory to somewhere more permanent.

  6. Add the location to your path in your current session, and also in your shell profile/resource file to make it take effect on every login:

     export PATH=$HOME/Downloads/instantclient_12_1:$PATH
    
  7. Enjoy.

    MacBook:Downloads alex$ export PATH=$HOME/Downloads/instantclient_12_1:$PATH
    MacBook:Downloads alex$ which sqlplus
    /Users/alex/Downloads/instantclient_12_1/sqlplus
    MacBook:Downloads alex$ sqlplus
    
    SQL*Plus: Release 12.1.0.2.0 Production on Thu Jun 9 16:29:49 2016
    
    Copyright (c) 1982, 2016, Oracle.  All rights reserved.
    
    Enter user-name: 
    

El Capitan added system integrity protection (SIP), and one side effect of that is that exporting DYLD_LIBRARY_PATH doesn't work. That could affect running SQL*Plus from a shell script, for example. There are workarounds for the 11g instant client. The installation notes at the bottom of the download page have changed since I last did this, and it now says to hard link the library files to the user's ~/lib directory to avoid that issue. Fortunately it looks like you don't need to worry about that with the 12c client - they've fixed the way it's built.

Community
  • 1
  • 1
Alex Poole
  • 183,384
  • 11
  • 179
  • 318
  • Will give this a shot and report back, thanks for the info. – Ben Jun 08 '16 at 23:49
  • So two things I want to clarify. 1. I can drop all instant client files (including sqlplus) into a single directory? and 2. I just go into my bash profile (in this case .zshrc) and add the instantclient directory path to my $PATH ? I just want to clarify because it's still not working. – Ben Jun 09 '16 at 15:16
  • For (1) yes, they have to be unzipped into the same directory, for the library dependencies to work. For (2) are you exporting the updated PATH? And can you run `sqlplus` from the directory those files are in, but not anywhere else? – Alex Poole Jun 09 '16 at 15:18
  • no matter which directory I am in, if i type sqlplus in terminal, it says "command not found", I have export PATH in my .zshrc with the path to the instantclient directory, which is /Users/bdonna/Downloads/instantclient_12_1 – Ben Jun 09 '16 at 15:30
  • Have you also done that export in your current shell, or re-sourced your .zshrc, or started a new shell? Adding it to the file makes it automatic on next log in, guess that wasn't obvious... And if you're in the directory you can do `./sqlplus`, I forgot it excludes the current directory by default. – Alex Poole Jun 09 '16 at 15:33
  • So I can do something like this for the path line right? export PATH="/opt/local/bin:/opt/local/sbin:/Users/bdonna/.rbenv/shims:/Users/bdonna/Downloads/instantclient_12_1 – Ben Jun 09 '16 at 18:44
  • @ben - yes, though it's more usual to extend the existing value with `export PATH=$HOME/Downloads/instantclient_12_1:$PATH`. (Double-quotes aren't needed, but should be balanced if you use them - that was probably a copy/pasrte glitch.) Just noticed I had an invalid path inmy answer so I've changed that. – Alex Poole Jun 09 '16 at 18:50
  • @ben - from your new question, this still isn't working for you? Not sure what you're doing differently, I pasted exactly what I did installing from scratch, from fresh downloads. – Alex Poole Jun 14 '16 at 16:55
  • I think the issue I had was I could not establish connection via jdbc with sqlplus, it sounds like sqlcl has better support for jdbc? I have installed sqlcl as you suggested in response to my other post, and I am now trying to establish connection. – Ben Jun 15 '16 at 18:09
  • @ben - SQL\*Plus isn't Java so isn't using JDBC, but does allow similar URLs ('easy connect'), e.g. `sqlplus user/password@//host:1521/service`. SQLcl is is written in Java and runs in a JVM so it is using JDBC (as is SQL Developer). But anything you can connect to from SQL Developer you can connect to from SQL\*Plus. Maybe you had network/firewall issues? – Alex Poole Jun 15 '16 at 18:25
  • Yea that makes sense, the only way I could connect in SQLDeveloper was with jdbc for some reason, so since SQLplus doesnt support jdbc, it was a no go. I am now using sqlcl, but unable to establish connection via jdbc, see my new post http://stackoverflow.com/questions/37843426/why-cant-i-connect-via-jdbc-using-sqlcl – Ben Jun 15 '16 at 18:47
  • SQL Develoepr *only* uses JDBC. From that question were you putting `vdbsl14` in the connection panel's Service Name box, and that got the same ORA-12514? If you'd put that in the SID box instead it would probably have worked. – Alex Poole Jun 15 '16 at 19:20
  • The path above gave me errors. In case it helps anyone else I used: `export PATH="/Users/zaheeram//Downloads/instantclient_12_1:$PATH"` – Zaheer Jan 19 '17 at 00:57
  • I created an installation shell script to automate the install instructions https://gist.github.com/rcbop/d8d868f4a100e1ac4b36c6ca93a5aeaf You just need to place the sdk and basic instant client zip files in the same place as this script and run it as root! – Rogério Peixoto Nov 09 '17 at 21:00
  • I don't rename my files. I put them on my home. I unzip both by terminal. Then, I wrote: export PATH="/Users/adrianagiuliano/Desktop/instantclient-basic-macos.x64-18.1.0.0.0.zip:$PATH" but when I wrote: which sqlplus I have: -bash: which: command not found I tried also with: which sqlplus /Users/adrianagiuliano/Desktop/instantclient-basic-macos.x64-18.1.0.0.0.zip The answer is the same. With is a command not found. – Sam May 31 '19 at 08:23
  • @Adryr83 - you don't put the **zip file** in your path, you put the expanded folder in your path. That folder has the `sqlplus` executable in it. – Alex Poole May 31 '19 at 08:37
  • Ok, @AlexPoole, I write: export PATH="/Users/adrianagiuliano/Desktop/instantclient-basic-macos.x64-18.1.0.0.0:$PATH" and then: which sqlplus /Users/adrianagiuliano/Desktop/instantclient-basic-macos.x64-18.1.0.0.0 But when I try the command: sqlplus, I see: sqlplus: command not found – Sam May 31 '19 at 09:09
  • @Adryr83 - isn't your unzipped directory called `instantclient_18_1`, rather than `instantclient-basic-macos.x64-18.1.0.0.0`? – Alex Poole May 31 '19 at 09:20
  • Ok, @AlexPoole, now it's better but not fine. I wrote the right commands, but when I wrote sqlplus, the answer of my terminal is: dyld: Library not loaded: @rpath/libclntsh.dylib.18.1 Referenced from: /Users/adrianagiuliano/Desktop/instantclient_18_1/sqlplus Reason: image not found Abort trap: 6 – Sam May 31 '19 at 09:47
20

Using Homebrew (https://brew.sh/) simple as that:

$ brew tap InstantClientTap/instantclient
$ brew install instantclient-basic
$ brew install instantclient-sqlplus

No additional libs needed in my case. Depending on your shell - rehash could be needed.

Janusz
  • 1,343
  • 11
  • 16
0

Within SQLdeveloper you will find SQLplus, that works out of the box like on Windows.

SQLDeveloper example

(Should start like this)

If you move the app under Application and manage to start up the SQLdeveloper-client you cant fint it here, called sql:

/Applications/SQLDeveloper.app/Contents/Resources/sqldeveloper/sqldeveloper/bin/sql

To directly login, run sql and exit:

sql username/password@ADDRESS_TO_DB:1521/SID @/path/to/your/pls_file_containing_sql/test.pls

Remember to include 'exit;' at the end of your pls-file.

Punnerud
  • 7,195
  • 2
  • 54
  • 44