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
Vish
August 3, 2008Hi,
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
Danilo Vizzarro
August 3, 2008Can you try to execute SqlPlus as root? Do you have the same error?
Vish
August 3, 2008Hi,
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
Danilo Vizzarro
August 5, 2008Hi 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
Kerby
August 14, 2008Question:
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.
Danilo Vizzarro
August 15, 2008Hi 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
artulo
August 15, 2008I’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
Danilo Vizzarro
August 18, 2008Hi artulo,
try to create manually the .profile file in the home directory as I described to Vish ;P
pritesh
September 10, 2008i 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?
kerby
September 16, 2008Yes, 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
artulo
October 14, 2008THANK 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.
Danilo Vizzarro
October 16, 2008Hi Kerby,
# cd
# ./TNSconnectMac.sh
then make sure that the information you are typing are right :P
Danilo Vizzarro
October 16, 2008Hi pritesh,
sorry but we cannot help you with windows… you should start to use Linux :P
Bye
Robert
October 16, 2008Hi,
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: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
/usr/lib/libclntsh.dylib.10.1: unknown file type, first eight bytes: 0x0B 0x00 0x00 0x00 0x14 0x05 0x00 0x00
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
Michael Caraballo
October 27, 2008I 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
Michael
November 12, 2008Attempting 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.
Pete Ludwig
November 16, 2008I 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.
Beiowolf
April 23, 2009Hi
How to uninstall this on Mac OSX ?
pklammer
July 25, 2011i 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
Amey
January 9, 2012Hi,
I have Lion OS, i need to install SQL plus Oracle..how should i go about it
Regards,
Amey
Luthien
January 30, 2012Thank you! This finally led me to getting SQLPlus to work on Lion, which saves me a lot of hassle working via terminal server.
Luthien
January 30, 2012oh, 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).
deepak
May 22, 2012i 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
manichandra
June 22, 2012i 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#
manichandra
June 22, 2012and 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
matt snider
March 23, 2013Just 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