Error establishing a database connection -- wp-config already updated



In the Dreamhost databases panel, I noticed an auto-generated username and password for one of my Wordpress databases. For consistency, I decided to grant my normal database user (me) access to the database, with my regular password, and deleted the auto-generated user. I then went to wp-config and updated the User and Password to reflect the changes I’d just made in Dreamhost.

Now, a couple of days later, I see “Error establishing a database connection” for my website. I triple-checked the user/password info in Dreamhost and in my wp-config, and the info is the same (with no extra spaces, either).

What did I miss? How can I fix it? I’d revert back to the old user and pass, but I didn’t write them down.


So it worked correctly at first then broke?


I’m not positive. I think I checked it to make sure it worked (immediately after changing the user/password in Dreamhost and in wp-config), but now I’m second guessing myself. My other websites/databases are working, just this one is zonked, where I made the change (so I’m assuming it’s due to the change, though I guess I can’t be sure about that, either).

I found a backup of the wp-config, so I have the old auto-generated user and pass, which I re-added to Dreamhost and changed in the config file. So, in theory, everything is back to the way it was before it broke, but it’s still not working after a couple of hours.


The only thing that I can think of is that I think this type of thing can happen during server moves. Like dreamhost copies files to a new server, then you change a file on old server before DNS changes, then dreamhost changes the DNS for your domain and suddenly you are using and old version of the file. Thing is tho, you wouldn’t see the updated info in the WP config when you reopened it.

Another possibility: Go “manage domains” in the dreamhost panel, and check what “user” is listed for the server user. Maybe there is a set of files under and “old” user that you are changing, and the domain is really running on another set of files from another user. NOTE: in this sentence i’m not speaking of mysql users, but shell/ftp users.


And I’m back! It was a silly mistake. I have a handful of domains/subdomains and old test installations of WordPress. The other day I was trying to clean stuff up by deleting what I don’t use anymore. While I managed to not delete the desired database, I DID delete the hostname for that specific database–thus, the wp-config file couldn’t find it.

In Dreamhost’s MySQL Databases panel, I saw the list of hostnames and realized the hostname was gone. I also saw, “Hostnames (these are all interchangeable),” so I simply entered one of those in the DB_HOST section of wp-config instead. My site is now loading.

Thanks, LakeRat. Even if your advice didn’t solve the issue, it got me looking at the problem differently, which is exactly what I needed.