Search code examples
linuxsqlplusoracle12ctns

unable to connect to DB using sqlplus: ORA-12154: TNS:could not resolve the connect identifier specified


I'm trying to connect to connect to DB through sqlplus from one of the Linux servers, but getting below error:

SQL*Plus: Release 12.1.0.2.0 Production on Thu May 16 15:49:15 2019

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

ERROR:
ORA-12154: TNS:could not resolve the connect identifier specified


Enter user-name:

I re-installed oracle client in my server, hoping it'll resolve the issue,but no luck!

Usage:

$>sqlplus user_name/passwd@SID

Any help is most welcome!!!


Solution

  • That happens when you're trying to connect to a database whose alias isn't contained in the TNSNAMES.ORA file. For example:

    SQL> connect scott/tiger@does_not_exist
    ERROR:
    ORA-12154: TNS:could not resolve the connect identifier specified
    
    
    Warning: You are no longer connected to ORACLE.
    SQL>
    

    So, check what's written in TNSNAMES.ORA you use.


    Note that mostly every Oracle software product you install contains its own TNSNAMES.ORA file. If that's your situation as well, I'd suggest you to:

    • create a directory on your hard disk (for example, c:\oralib)
    • put one of TNSNAMES.ORA files in there
    • copy/paste all databases you're accessing into that file
    • create environment variable named TNS_ADMIN which will point to that directory
    • doing so, every Oracle product will look only at that TNSNAMES.ORA file
    • furthermore, it means that you'll have to maintain only one copy of the file, not all of them