In this article, I will share the necessary steps to connect to Oracle through the linux operating system and the solutions to the problems we face.
First, we connect to the linux server with ssh as root.
Then, with the help of the following command, we ask where sqlplus is.
1 | [root@localhost /]# find / -name "*sqlplus*" |
We get a list below.
1 2 3 4 5 6 7 8 9 10 11 | /root/oracle-instantclient12.2-sqlplus-12.2.0.1.0-1.x86_64.rpm /var/lib/yum/yumdb/o/d19102c309911ffe91d7c52dcf90fc12105efb20-oracle-instantclient12.2-sqlplus-12.2.0.1.0-1-x86_64 /usr/bin/sqlplus64 /usr/lib/oracle/12.2/client64/bin/sqlplus /usr/lib/oracle/12.2/client64/lib/libsqlplus.so /usr/lib/oracle/12.2/client64/lib/libsqlplusic.so |
From this list, we see that sqlplus is in the “/usr/lib/oracle/12.2/client64/bin” directory.
So we find out that Oracle Home is in the directory “/usr/lib/oracle/12.2/client64”.
With the following command, we are going to the directory where sqlplus is.
1 | cd /usr/lib/oracle/12.2/client64/bin/ |
We are running sqlplus with the following command.
1 | [root@localhost bin]# ./sqlplus |
When we run sqlplus, we get an error as follows.
./sqlplus: error while loading shared libraries: libsqlplus.so: cannot open shared object file: No such file or directory
We then run the following commands to load Oracle Home and Library Path.
1 2 3 | [root@localhost bin]# export ORACLE_HOME=/usr/lib/oracle/12.2/client64 [root@localhost bin]# export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib:$ORACLE_HOME |
When we want to run sqlplus again as below, it asks us the username.
1 2 3 4 5 6 | [root@localhost bin]# ./sqlplus <em>SQL*Plus: Release 12.2.0.1.0 Production on Fri Oct 12 09:16:24 2018 </em><em>Copyright (c) 1982, 2016, Oracle. All rights reserved. </em><em>Enter user-name: </em>Terminate with the command "Ctrl C".<em> </em> |
Once you see that we can connect, you can connect to the Oracle database you want with the command below.
1 | [root@localhost bin]# ./sqlplus yourusername/yourpassword@oraclehostname_or_oracleip:oracleport/oracle_service_name |
Example:
1 | [root@localhost bin]# ./sqlplus john/1234@testdb-scan:1521/TESTDB |
Thanks for sharing. It will be good to add Home and Library Path to the .bash_profile of the oracle user. This will make the environment variables persistent.