Oracle Sqlplus client on Mac

Ryainad picture Ryainad · Oct 3, 2013 · Viewed 19.5k times · Source

I want to install SqlPlus client on my Mac, which is 64-bit. Firstly, I installed sqlplus for 64-bit, but I had error: "Segmentation fault: 11" Then I installed sqlplus for 32-bit, but still have a problem it says: ../libsqlplus.dylib: no suitable image found ../libsqlplus.dylib: mach-o, but wrong architecture

I have used many tutorials, but still didn't solve this problem.

Answer

Alex Poole picture Alex Poole · Oct 3, 2013

The 11gR2 64-bit instant client works on 10.8.5. It doesn't matter if the database you're connecting to is still 10g, you can use the 11g client. I'm not aware of any reason to still use the old version, unless maybe you need a specific ojdbc version; but presumably there are use cases or it wouldn't still be listed prominently for download. Anyway, this demonstrates a fresh install:

$ unzip instantclient-basic-macos.x64-11.2.0.3.0.zip
Archive:  instantclient-basic-macos.x64-11.2.0.3.0.zip
  inflating: instantclient_11_2/BASIC_README  
  inflating: instantclient_11_2/adrci  
  inflating: instantclient_11_2/genezi  
  inflating: instantclient_11_2/libclntsh.dylib.11.1  
  inflating: instantclient_11_2/libnnz11.dylib  
  inflating: instantclient_11_2/libocci.dylib.11.1  
  inflating: instantclient_11_2/libociei.dylib  
  inflating: instantclient_11_2/libocijdbc11.dylib  
  inflating: instantclient_11_2/ojdbc5.jar  
  inflating: instantclient_11_2/ojdbc6.jar  
  inflating: instantclient_11_2/uidrvci  
  inflating: instantclient_11_2/xstreams.jar  

$ unzip instantclient-sqlplus-macos.x64-11.2.0.3.0.zip
Archive:  instantclient-sqlplus-macos.x64-11.2.0.3.0.zip
  inflating: instantclient_11_2/SQLPLUS_README  
  inflating: instantclient_11_2/glogin.sql  
  inflating: instantclient_11_2/libsqlplus.dylib  
  inflating: instantclient_11_2/libsqlplusic.dylib  
  inflating: instantclient_11_2/sqlplus  

$ export DYLD_LIBRARY_PATH=$PWD/instantclient_11_2
$ $PWD/instantclient_11_2/sqlplus

SQL*Plus: Release 11.2.0.3.0 Production on Thu Oct 3 09:49:06 2013

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

Enter user-name: 

You can create a tnsnames.ora anywhere; I put this in the same instant client_11_2 directory:

$ export TNS_ADMIN=$PWD/instantclient_11_2
$ echo "TEST =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = <db_server>)(PORT = <listener port>))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = <full_db_service_name>)
    )
  )
" > $TNS_ADMIN/tnsnames.ora

$ $PWD/instantclient_11_2/sqlplus user/password@test

SQL*Plus: Release 11.2.0.3.0 Production on Thu Oct 3 09:55:14 2013

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options

SQL> 

The 32-bit version works fine too:

$ rm -rf $PWD/instantclient_11_2
$ unzip instantclient-basic-macos.x32-11.2.0.3.0.zip
$ unzip instantclient-sqlplus-macos.x32-11.2.0.3.0.zip
$ export DYLD_LIBRARY_PATH=$PWD/instantclient_11_2
$ export TNS_ADMIN=$PWD/instantclient_11_2
$ echo "TEST = ..." > TNS_ADMIN/tnsnames.ora
$ $PWD/instantclient_11_2/sqlplus user/password@test

SQL*Plus: Release 11.2.0.3.0 Production on Thu Oct 3 10:06:19 2013

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options

SQL> 

You can of course move or rename the instanstclient_11_2 directory to anything you want, just make sure your DYLD_LIBRARY_PATH, TNS_ADMIN and (to make life easier) PATH environment variables follow it. If you have more than one version installed make sure the variables only point to one version at a time so you pick up the right libraries etc. (If you do have multiple versions, making TNS_ADMIN somewhere central makes much more sense as you only need to maintain one copy of tnsnames.ora).

I'd need to check, but I think you might have to still use the 32-bit version if you're connecting from Java; it has to batch the architecture of Java itself so I guess it depends which version of that you have installed.