Today I wrote this script that can be used to install and configure SqlPlus on a Mac OS X. It was tested on a Leopard 10.5.4 machine.

Pre-installation:
1. Download from the Oracle website the Oracle Client for Mac OS X (Intel x86) Version 10.2.0.4 and the SqlPlus:
- the Oracle Client ‘Instant Package – Basic’ [instantclient-basic-macosx-10.2.0.4.0.zip]
- the Oracle Client ‘Instant Package – SqlPlus‘ [instantclient-sqlplus-macosx-10.2.0.4.0.zip]
2. Download the bash scripts MacSqlPlus.sh and TNSconnectMac.sh. Last version can be found in the script page.

Installation:
1. Set a root password and log in as root
# sudo passwd
# su -
2. Copy the files instantclient-basic-macosx-10.2.0.4.0.zip, instantclient-sqlplus-macosx-10.2.0.4.0.zip, MacSqlPlus.sh and TNSconnectMac.sh into the directory /var/root.
3. Enter the home directory of the user root, change the permissions of the scripts and execute the installation script.
# cd
# chmod 755 MacSqlPlus.sh TNSconnectMac.sh
# ./MacSqlPlus.sh

Post-Installation: [Steps Required]
1. Make sure you know SID, SERVER and PORT of the server you want to connect.
2. Execute the script TNSconnectMac.sh
# cd
# ./TNSconnectMac.sh
3. Type: Oracle SID, Oracle Server, Oracle Server Port, Oracle Database Username, Oracle Database Password.

Installation Check:
1. To connect the Oracle DB via SqlPlus you can run the following command:
# sqlplus DB_USER/DB_PASS@//DB_SERVER:DB_PORT/DB_SID

Your comment, error reports and improvement requests are always welcome ;D




Other Posts
Comments

This entry was posted on Friday, July 25th, 2008 at 10:19 pm and is filed under Oracle on Unix Server. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
26 Comments so far

  1. Vish on August 3, 2008 5:40 am

    Hi,
    Thanks for the detailed steps. After doing this I was unable to connect and was getting below error
    dyld: Library not loaded: /scratch/plebld/208/sqlplus/lib/libsqlplus.dylib
    Referenced from: /usr/bin/sqlplus
    Reason: image not found
    Then I have exported DYLD_LIBRARY_PATH variable
    bash-3.2# export DYLD_LIBRARY_PATH=/opt/oracle/instantclient_10_2
    bash-3.2# echo $PATH $DYLD_LIBRARY_PATH
    /bin:/usr/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin /opt/oracle/instantclient_10_2
    Later I tried connecting but still have some issue
    bash-3.2# sqlplus hr/hr@//172.16.127.130:1521/XE

    SQL*Plus: Release 10.2.0.4.0 – Production on Sun Aug 3 11:25:38 2008

    Copyright (c) 1982, 2007, Oracle. All Rights Reserved.

    ERROR:
    ORA-12170: TNS:Connect timeout occurred

    I am able to ping the Oracle host machine.
    bash-3.2# ping 172.16.127.130
    PING 172.16.127.130 (172.16.127.130): 56 data bytes
    64 bytes from 172.16.127.130: icmp_seq=0 ttl=128 time=0.669 ms
    64 bytes from 172.16.127.130: icmp_seq=1 ttl=128 time=0.971 ms
    64 bytes from 172.16.127.130: icmp_seq=2 ttl=128 time=0.610 ms

    I tried increasing SQLNET.INBOUND_CONNECT_TIMEOUT = 360 in sqlnet.ora but nothing worked.
    Pls help
    Vish

  2. Danilo Vizzarro on August 3, 2008 11:36 am

    Can you try to execute SqlPlus as root? Do you have the same error?

  3. Vish on August 3, 2008 5:13 pm

    Hi,
    Thanks for the prompt response. yes I tried as root. I uninstalled everything tried from scratch. Now i am getting below error.
    root# echo $PATH $DYLD_LIBRARY_PATH
    /bin:/usr/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin /opt/oracle/instantclient_10_2
    root# sqlplus hr/hr@//172.16.127.130:1521/XE
    dyld: Library not loaded: /scratch/plebld/208/rdbms/lib/libclntsh.dylib.10.1
    Referenced from: /usr/bin/sqlplus
    Reason: image not found
    Trace/BPT trap

  4. Danilo Vizzarro on August 5, 2008 5:24 pm

    Hi Vish,
    are you using Leopard 10.5.4?

    Try to run this

    # cd
    # chmod 755 .profile
    # nano .profile

    and add at the end of the file .profile the following strings:

    DYLD_LIBRARY_PATH=”/opt/oracle/instantclient_10_2″
    export DYLD_LIBRARY_PATH
    TNS_ADMIN=/opt/oracle/tns
    export TNS_ADMIN
    ORACLE_HOME=”/opt/oracle/instantclient_10_2″
    export ORACLE_HOME

    Then restart close the terminal and open it again.
    Enjoy

  5. Kerby on August 14, 2008 5:44 pm

    Question:
    This did not work for me. I am trying to connect to
    Oracle 7.3.4 and that maybe the problem.
    I know I can download ‘classes12′ and that is supposed to be the driver for this version of Oracle’s DB… but where do I put that classes12.zip?
    Or, am I missing something…
    The error is:

    SQL*Plus: Release 10.2.0.4.0 – Production on Thu Aug 14 10:43:30 2008

    Copyright (c) 1982, 2007, Oracle. All Rights Reserved.

    Enter user-name: my_user_name
    Enter password: my_password
    ERROR:
    ORA-12162: TNS:net service name is incorrectly specified

    Any help would be appreciated. Thanks.

  6. Danilo Vizzarro on August 15, 2008 8:05 am

    Hi Kerby,
    make sure that you specified correctly the SID.
    # cat /opt/oracle/tns/tnsnames.ora
    You can edit this file manually.
    # vi /opt/oracle/tns/tnsnames.ora
    Bye

  7. artulo on August 15, 2008 8:03 pm

    I’m getting a similar error, but it’s with the webserver starting.

    dyld: NSLinkModule() error
    dyld: Library not loaded: /scratch/plebld/208/rdbms/lib/libclntsh.dylib.10.1
    Referenced from: /usr/lib/php/extensions/no-debug-non-zts-20060613/oci8.so
    Reason: image not found

    output from your instructions above:

    ls

    BASIC_README libclntsh.dylib.10.1 libocijdbc10.jnilib
    SQLPLUS_README libnnz10.dylib libsqlplus.dylib
    classes12.jar libocci.dylib libsqlplusic.dylib
    genezi libocci.dylib.10.1 ojdbc14.jar
    glogin.sql libociei.dylib sdk
    libclntsh.dylib libocijdbc10.dylib sqlplus

    also, I don’t have a .profile file

  8. Danilo Vizzarro on August 18, 2008 9:14 pm

    Hi artulo,
    try to create manually the .profile file in the home directory as I described to Vish ;P

  9. pritesh on September 10, 2008 10:46 am

    i want to install oracle 10g client(32-bit) on Windows 64-bit OS. i am also able to install it..but the problem is that there is no ora driver in driver list. so i am unable to make DSN.
    can anybody help me?

  10. kerby on September 16, 2008 5:29 pm

    Yes, I am revisiting this. It still does not connect. I have the correct info and sid set properly. The error is: TNS could not resolve the connect identifier

  11. artulo on October 14, 2008 10:57 pm

    THANK YOU!!! It works!!

    I also ended up having to put the instantclient libraries into /usr/lib and /scratch/plebld/208/rdbms/lib, then creating symbolic links to libclntsh.dylib.10.1.

  12. Danilo Vizzarro on October 16, 2008 5:27 pm

    Hi Kerby,

    # cd
    # ./TNSconnectMac.sh

    then make sure that the information you are typing are right :P

  13. Danilo Vizzarro on October 16, 2008 5:28 pm

    Hi pritesh,
    sorry but we cannot help you with windows… you should start to use Linux :P
    Bye

  14. Robert on October 16, 2008 10:50 pm

    Hi,
    I got almost the same error over and over again.

    localhost:~ root# sqlplus
    dyld: Library not loaded: /scratch/plebld/208/rdbms/lib/libclntsh.dylib.10.1
    Referenced from: /usr/bin/sqlplus
    Reason: no suitable image found. Did find:
    /scratch/plebld/208/rdbms/lib/libclntsh.dylib.10.1: unknown file type, first eight bytes: 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00
    /usr/lib/libclntsh.dylib.10.1: unknown file type, first eight bytes: 0x0B 0×00 0×00 0×00 0×14 0×05 0×00 0×00
    Trace/BPT trap

    I did set the Library Path and copied the libraries both to usr/lib and scratch/…. but nothing changes.

    Could you plz help me

    Greets

    Robert

  15. Michael Caraballo on October 27, 2008 11:19 pm

    I got the instant client working just fine with this script but it only works insofar as I am logged in as user “admin” on my system. When I log in as user “root”, sqlplus fails with message:

    “PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib/php/extensions/no-debug-non-zts-20060613/oci8.so’ – (null) in Unknown on line 0″.

    When I echo $DYLD_LIBRARY_PATH as user root it displays no set value. It works just fine when I change to user “admin” at the bash command shell.

    If I run a script with a line that reads “phpinfo()” and execute it via the command line as root, the OCI extension is listed as loaded. Furthermore I can execute Oracle function calls from php scripts so long as the scripts are called from the command line.

    When I instead call a webpage with phpinfo() the OCI8 extension is not listed as loaded.

    Lastly when apache2 starts, php throws an error message to its log file which says “PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib/php/extensions/no-debug-non-zts-20060613/oci8.so’ – (null) in Unknown on line 0″

    Do I have a problem with variables not being persistent after reboot or being set across multiple users accounts? Perhaps when Apache is running it can’t talk to the instant client.

    Any ideas?

    Thanks,
    –Mike C

  16. Michael on November 12, 2008 11:41 pm

    Attempting to install Oracle Administrator Client 10.2.0.4 on MAC OS X 10.5.4. I log in as root, I set ORACLE_HOME and DYLD_LIBRARY_PATH then unzip the downloaded client software. No errors and for some reason no install logs. Anyway, when logged in as root or as myself when I try to launch sqlplus I receive the error:
    dylb: Library not loaded: /scratch/plebld/208/sqlplus/lib/libsqlplus.dylib
    Referenced from /Users/user1/Oracle/ohome/bin/./sqlplus
    Reason: image not found
    Trace/BPT trap

    Please help if you can.

  17. Pete Ludwig on November 16, 2008 5:42 am

    I went as root to /etc/profile and added the following:

    # Oracle Client changes
    DYLD_LIBRARY_PATH=/opt/oracle/instantclient_10_2
    export DYLD_LIBRARY_PATH
    TNS_ADMIN=/opt/oracle/tns
    export TNS_ADMIN
    ORACLE_HOME=/opt/oracle/instantclient_10_2
    export ORACLE_HOME

    - please note two things:

    1. OSX is whiny about changing big boy files, so you’ll have to save with :w! in vi before you can :q out of there. I like putting stuff here I want across users, although the other good (better, safer) way to do it is to pick who accesses the file and just change their ~/.profile files by adding the above. Forcing yourself to login as root to do some web or dev DB stuff ain’t a good plan.

    2. bash (at least my current OSX version) doesn’t like the double quotes around the roughly exact same thing Danilo had written earlier, I just took them out. I was getting that crappy “dylb: Library not loaded: /scratch..” error until I changed that.

    Thanks for the scripts, Danilo. Saved me some time and headache getting this tweaky Mac version hooked up.

  18. Beiowolf on April 23, 2009 6:45 am

    Hi
    How to uninstall this on Mac OSX ?

  19. pklammer on July 25, 2011 7:00 pm

    i get the following error, can someone help me?

    sqlplus
    dyld: Library not loaded: /b/227/rdbms/lib/libclntsh.dylib.10.1
    Referenced from: /usr/bin/sqlplus
    Reason: image not found
    Trace/BPT trap: 5

  20. Amey on January 9, 2012 12:35 am

    Hi,

    I have Lion OS, i need to install SQL plus Oracle..how should i go about it

    Regards,

    Amey

  21. Luthien on January 30, 2012 2:13 pm

    Thank you! This finally led me to getting SQLPlus to work on Lion, which saves me a lot of hassle working via terminal server.

  22. Luthien on January 30, 2012 2:15 pm

    oh, btw – @pklammer: I had this error as well. You need to add some lines to your ~.bash_profile:

    DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/opt/oracle/instantclient_10_2
    export DYLD_LIBRARY_PATH
    TNS_ADMIN=/opt/oracle/instantclient_10_2
    export TNS_ADMIN
    PATH=$PATH:/opt/oracle/instantclient_10_2
    export PATH

    and source it (or open another Terminal tab).

  23. deepak on May 22, 2012 9:18 am

    i got this error

    when i run sqlplus

    dyld: Library not loaded: /b/227/sqlplus/lib/libsqlplus.dylib
    Referenced from: /usr/bin/sqlplus
    Reason: image not found
    Trace/BPT trap: 5

  24. manichandra on June 22, 2012 10:41 am

    i am getting this error. I tried twice from the scratch. I am using lion
    I changed .profile also.
    and i directly copied tnsnames.ora which my professor asked me to use.

    [MANICHANDRABHOOSHANs-MacBook-Pro:/] root# sqlplus cs457_9884/changeme@//216.133.192.38:1521/npu8ora
    dyld: Library not loaded: /b/227/rdbms/lib/libclntsh.dylib.10.1
    Referenced from: /usr/bin/sqlplus
    Reason: image not found
    Trace/BPT trap
    [MANICHANDRABHOOSHANs-MacBook-Pro:/] root#

  25. manichandra on June 22, 2012 10:49 am

    and when i run ./MacSqlPlus.sh
    I got this No file or directory message in the end. I don’t know its an error or no.

    inflating: instantclient_10_2-3.zip/ojdbc14.jar
    inflating: __MACOSX/instantclient_10_2-3.zip/._ojdbc14.jar
    inflating: __MACOSX/._instantclient_10_2-3.zip

    3 archives were successfully processed.
    1 “zipfile” was a directory.
    ./MacSqlPlus.sh: line 34: cd: /opt/oracle/instantclient_10_2: No such file or directory

    You can now execute the script TNSconnect.sh to set up the tnsnames.ora
    After that you can connect your Oracle DB via Sqlplus using this command:
    sqlplus DB_USER/DB_PASS@//DB_SERVER:DB_PORT/DB_SID

  26. matt snider on March 23, 2013 1:56 am

    Just wanted to share some pointers from my experience:

    * Instead of logging in as root, I was just able to everything using SUDO.
    * The latest version was 11.2, but 10_2 is hardcoded in the scripts. You will have to manually changed the filenames in the MacSqlPlus.sh script, if you use a never version.
    * I got it working on OSX Mountain Lion
    * You will have issues with DYLD, I created an alias that sets up the right DYLD location: alias run_sqlplus=”DYLD_LIBRARY_PATH=/opt/oracle/instantclient_11_2/ sqlplus”
    * I had to set the TNS_ADMIN variable for it tnsnames.ora to work correction: export TNS_ADMIN=/opt/oracle/tns/tnsnames.ora

    That’s it,
    -matt

Name (required)

Email (required)

Website

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Share your wisdom