After a basic, successful installation of Oracle 11g, I ran dbca
again to enable Enterprise Manager on my database. The operation hung at around 67% for half an hour or more, so I clicked Stop to abort the operation. Things seemed to wrap up cleanly, EM was working, all was well with the world.
Then I started getting this dreaded error upon any attempt to connect in SQL*Plus:
ORA-12154:
TNS:could not resolve the connect identifier specified
I thought perhaps the database had been corrupted due to the earlier aborted operation, so I ran dbca
again and deleted the database. Then I attempted to create a new database in its stead, using a clone of the template created the first time around. Unfortunately, the clone database operation fails at 50% with the exact same error:
ORA-12154:
TNS:could not resolve the connect identifier specified
How can I clean up the mess I have created, short of reinstalling Oracle entirely from scratch?
ORA-12154 indicates that the tnsnames.ora file does not contain the appropriate entry for the database you are attempting to connect to.
What OS are you using? Are you using DHCP on your Oracle server with Windows? If so, read this about Loopback Adapters and Oracle.
When you get a hang setting up enterprise manager, it's almost always because it's trying to quiesce the database into exclusive mode. I'm not sure why it needs to do that but it does it. Any interactive sessions you might have open will hold it up.
As far as the tnsnames problem, find the tnsnames.ora file and see if it's messed up. The location depends on your OS. On Unix systems it's in $ORACLE_HOME/network/admin/tnsnames.ora by default. I don't run Oracle server on Windows, so I'm not sure what the path is for that. It could have some half written junk in there from the abort that is preventing it from working when it adds the new database.
The problem seems to have been a nonconforming password. Using characters other than alphanumerics, #, $, and _ in your Oracle password will cause this error.