It seems that our common problem discussed in the WordPress data org forms these days is people having the problem with error message, “Error establishing a database connection” either on a blog that they’re initially setting up or they’ve tried to upgrade the blog and they get that error or they moved the blog to some of the location and they get the error message that says, “Error establishing a database connection.”
In this video, I want to go through a few of the possible causes of that and sort of talk you through it and show you what to check and show you some places to check using this test blog here.
As you can see, I have a blog installed at extremeclassroom.com/blog. It’s in a subdirectory. This is it and it’s working just fine. It’s a new blog. There’s nothing in it but everything is working as it should. So, let’s go now to my hosting Control Panel. This one is hosted at Bluehost but what I’ll show you here will apply to virtually any host because the error establishing database connection is usually going to be in your PHP config file. There is something wrong. It’s not finding your database.
So, let’s look at this one for a second. I am going to click File Manager and you can go to File Manager from your Control Panel or you can go look at your blog through FTP, however you normally get to it but I am going in public_html in the blog subdirectory. That’s where my blog is located and I am going to open the wp-config file just to look at it. I’ll click on Edit here and open that file. Now, you could open yours again in your FTP client or however you get to your file structure.
If you get the problem with error establishing database connection, it’s probably going to be 99% chance that it’s going to be in this DB_NAME here. Your database name is incorrect or your database user is incorrect. Your database password could be incorrect or your database host could be incorrect. Chances are it’s going to be in one or more of those settings. So, if you get that error, you need to come here and look at these settings and make sure that they are correct.
Now, let’s just see what happens. If I were to come and change my database name just about one character for example and click Save Changes and then go back out now to look at my blog that was functioning properly. I’ll hit refresh. Now, I get the “Error establishing database connection” because it can no longer find that database. The name that I put in my wp_cofig.php file does not match the name of the database. So, if I have that problem, what I should do, if you have a hosting account with cPanel or some other hosting account so that you can actually go in and look at your databases. Chances are you’re going to be able to do that if you’re on a good host.
Here on Bluehost, I have MySQL Databases that I can look at. So, I am going to click on the MySQL Databases and it will show me the databases that I have created here. Now, I only have one on this account but if I had more, there would just be additional rows. So, this is my database name. This is exactly what I need to put in that wp_config file for a database name. Typically, your account user name is going to be appended to the front of your actual database name. So, when I set this database up, I named it word99. The system appended my account here, hosting account user name to the front of word99. So, my database name is extremi1_word99. That’s what I have to have in that config file. I can look at my database user here. That’s the user name. It’s extremi1. It appends the account user name to the front of it and when I set up my user, I call my user Figaro. So, I can get those two pieces of information by looking at the database right here.
Now, I can’t get my user password look in here. If you don’t know what that user password is, then you need to find out what it is or possibly create a new user and add it to the database and I’ll show you how to do that in a second. But you can verify the first two bits of information, the database name and the database user by looking at this information. So, I know it’s extremi1_word99, extremi1_figaro for the database name and the user. So now, I could take that information and go back to my File Manager. Open the wp_config file and check to make sure that the database name and the database user are correct and if they’re correct, then it’s either going to be the user password or it’s going to be the DB host that is incorrect.
So, let’s fix the database name that I changed earlier. Put the one back at the end of it, so I know that’s my database name. That’s my user name. Click Save Changes and then go back and look at my blog to ensure that it’s working. Come here and I’ll hit Refresh and now, my blog is back. So, my blog is working.
Transcription by:
Scribe4you Transcription Services