Connecting to remote oracle db

mac os xoraclePHP

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 11.2.0.3.0 Production

Best Answer

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]