TNS:no listener error in Oracle XE after changing computer name

This morning at work when trying to log on to my computer I noticed not my username on login screen but the "admin". Well network IT guys were doing their job setting up their stuff. I changed login to my name and logged in successfully. All was fine until I tried to connect to my local Oracle XE database from my PHP application I was developing. Connection to Oracle on my Windows machine failed with error TNS:no listener.

What settings needs to be adjusted in Oracle XE after changing computer name on Windows.

tested to connect to Oracle in CMD using $ sqlplus - all good so database itself was running. So it must be just the listener, which is a separate process that runs on the database server computer, receives incoming client connection requests and manages the traffic of these requests to the database server. I tested listener then $ lsnrctl - tried commands status, start, something was not right ... then I realised the network IT guys must have changed something. Wait, I see, they changed my computer name from VLAD-PC to PC05.

That's it. Computer name is set as HOST in two Oracle config files: tnsnames.ora and listener.ora located somewhere like: C:oraclexeapporacleproduct11.2.0server etworkADMIN.

Edit both files (run notepad as administrator) and replace old computer name by new one (in my case VLAD-PC in my case by PC05).

Restart Oracle XE - from Start menu for Oracle Express Edition Start Stop Database and Start Database.

Luckily I had this experience before so fixing did not take long time but still took me some time to find out which files needs to be fixed. Finally I do have this blog which helps me next time and hope helps others too.

原文地址:https://www.cnblogs.com/sos-blue/p/3399120.html