0
votes

I need to connect to our front-end database through sqlplus. Here's the information for connecting:

username: user001
password: password
IP Address: localhost
SID: dev

After connecting the admin server and then the app server, I tried to use sqlplus and then inputted the information for connecting the front-end database but it's not successful:

[admin-user@admin-host ~]$ cat sshapp
[admin-user@admin-host ~]$ ssh -L 50001:10.100.100.10:11 -L 50002:10.100.100.10:8003 -L 50003:10.100.100.10:8004 -L 50004:10.100.100.10:8005 -L 50005:10.100.100.10:8006 app-user@app-host
[admin-user@admin-host ~]$ ./sshapp
***************************************************************************
NOTICE TO USERS

This computer system is the private .....
***************************************************************************
app-user@app-host's password: 
Last login: Fri Jun 26 14:21:33 2020 from admin-host.abc.edf
Authorized users only. All activity may be monitored and reported.
[app-user@app-host ~]$ sqlplus

SQL*Plus: Release 12.1.0.2.0 Production on Fri Jun 26 14:27:58 2020

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

Enter user-name: user001
Enter password: 
ERROR:
ORA-12154: TNS:could not resolve the connect identifier specified


Enter user-name: 

Why does the error "ORA-12154: TNS:could not resolve the connect identifier specified" exist? How should I fix it for connecting the database?

---Additional information----

I don't know the path where my oracle client is installed... but I can type "sqlplus" for using SQL*Plus after connecting to app server.

[app-user@app-host ~]$ sql (type "sql" + tab)
sqlite3 sqlj sqlldr sqlplus
[app-user@app-host ~]$ pwd 
/bd-user/home/app-user 

---Updated on 30 June 2020---

Finally, this userid can be logged in through sqlplus after asking my client to resetting the password. We asked for changing the password because that userid was eventually locked. I am not sure if my client change other properties of that userid or not. As this userid could not be logged in through sqlplus but it could be logged in through Oracle SQL developer of other machine.

Apart form this userid, we also have different userid for connecting different front-end databases in the same app server. However, a few of userids can not be logged in through sqlplus (ERROR: ORA-12154: TNS:could not resolve the connect identifier specified) but they can be logged in through Oracle SQL developer of other machine.

2
See detailed ORA-12154 troubleshooting guide: edstevensdba.wordpress.com/2018/09/19/troubleshooting-ora-12154pifor

2 Answers

0
votes

Try these options:

Specify the whole connect string at once:

sqlplus user001/password@dev

When prompted for username, provide database you're connecting to, e.g.

[app-user@app-host ~]$ sqlplus

Enter user-name: user001@dev
Enter password:
0
votes

I guess your app-server is a different server from the one you have your database. In this case, try this

Your APP Server where you run sqlplus is not the database server

# export ORACLE_HOME=/path_where_your_oracle_client_is_installed 
# cat $ORACLE_HOME/network/admin/tnsnames.ora 

dev =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = mydnshostname or myipdbhost)(PORT = myport))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = myservicename)
    )
  )

# tnsping dev

TNS Ping Utility for Linux: Version 11.1.0.0.2 on 15-FEB-2009 14:46:28

Copyright (c) 1997, 2009 Oracle Corporation.  All rights reserved.

Used parameter files:
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL =
TCP)(HOST = mydnshostname )(PORT = myport))) (CONNECT_DATA = (SERVICE_NAME =
myservicename)))
OK (10 msec)

If the result is ok

sqlplus user/pwd@dev

or

sqlplus 

Enter user-name: youruser@dev
Enter password:

Your APP Server is also your DATABASE server

In this case you have two options, same as before using a service name entry in your tnsnames.ora or locally using BEQ

# export ORACLE_HOME=/path_of_your_oracle_db_installation
# export ORACLE_SID=yoursid # you can figure it out from ps -ef | grep smon 
# export PATH=$ORACLE_HOME/bin:$PATH
# sqlplus 

Enter user-name: youruser
Enter password:

Keep also in mind that in any of both scenarios you can use direct connect without having a tnsnames.ora file in the form of. A tnsnames.ora is basically a file which contains entries to database connections which are identified by an alias.

# sqlplus user@//mydbhost:myport/mysid 

Enter password: