I am very new to system and db admin stuffs. Infact, I need to have my skills more improved in those areas. Anyways, I was trying to connect to a remote oracle database and use php oci8 library to talk with that db.

I installed the oracle basic package, sdk and sql plus. For testing the connectivity I ran sqlplus command from /usr/bin which prompts for username and password, If I provide the remote db username and pass it throws an error like this: ORA-12162: TNS:net service name is incorrectly specified.

Also, once I installed oci8. But it seems like oci8 functions are not recognized since the library is not properly installed? How can I check if the library is properly installed?

Update: My OS is Mountain Lion 10.8.4, PHP version is 5.4.10, SQL*Plus: Release Production

  • Is you database and php are on the same server ? Commented Sep 30, 2013 at 8:46
  • No, they're not.
    – N. F.
    Commented Sep 30, 2013 at 14:58

1 Answer 1


The error ORA-12162 is return because the client (sqlplus) doesn't manage to resolve the tns name provided:

 sqlplus user/passwd@ALIAS_TNS

The ALIAS_TNS have to be described in the tnsnames.ora file on the client side. Usually, this file is under ORACLE_HOME/network/admin.

Note that since Oracle 10g another connection syntax exist and does not require the tnsnames.ora. the syntax is:

sqlplus username/password@[//]host[:port][/service_name] 
  • running your second command returns a bunch of command suggestions.Something like this: SQLPlus: Release Production on Mon Sep 30 09:35:50 2013 Copyright (c) 1982, 2012, Oracle. All rights reserved. SQLPlus: Release Production Copyright (c) 1982, 2012, Oracle. All rights reserved. Use SQLPlus to execute SQL, PL/SQL and SQLPlus statements. ..... Does the mean connection established? How can I run a normal query then? Also, ORACLE_HOME is a directory? I dont find this. How to find that(or set that up if needed?).
    – N. F.
    Commented Sep 30, 2013 at 15:38
  • ORACLE_HOME is the directory where you have installed your oracle client. And for the 2nd bunch of command, do you have replaced the 'host' by the database server dns name or ip adresse, the 'port' by the listener port on which the oracle server is listening and the 'service_name' by the name of the database ? Commented Oct 1, 2013 at 7:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.