How to fix Error Establishing Database connection in wordpress
7K views
Jan 24, 2024
In this troubleshooting tutorial video, the presenter addresses the common WordPress issue of "Error Establishing Database Connection" and guides viewers on how to fix it. The video likely covers potential causes for this error, such as database configuration issues or server problems, and provides step-by-step instructions on resolving the issue. Viewers can expect practical insights into identifying and correcting database connection problems, ensuring that their WordPress websites are restored to proper functionality. Whether you're a website owner, administrator, or someone encountering this error, this video aims to offer a comprehensive guide for diagnosing and fixing the "Error Establishing Database Connection" problem in WordPress.
View Video Transcript
0:00
Hi everyone
0:01
Welcome to K2 blogging and in this video I will show you how you can fix this error
0:05
Error establishing a database connection. So when you login to your admin panel sometimes you will see a error message like this
0:13
Error establishing a database connection. So there are various reason you may see this error in your wordpress website
0:19
If the database credential is mismatched then you will see this error
0:23
Or if your database server is down then also you will see this message
0:28
Or the name server is not properly connected to your hosting. So if you just migrated your website from one hosting to other and the name server is
0:36
not properly connected to your hosting then also you will see this error
0:41
So let's check how you can fix this. And if you found this video helpful then make sure to hit the like button
0:47
So the first method you need to follow is to check the database login credential
0:53
So for this let me just login to the admin panel of the hostinger here
0:57
So here you need to search for the database. So if you are using cpanel you can search for phpmyadmin
1:04
And here you will see the database of your website. So here this is the database name and this is the database user
1:12
So make sure to copy these two values. So let me copy these two values from here
1:18
So let me quickly open a notepad file here. And let me copy the database user name as well
1:26
And I will paste the database user name here. Now you need to access your file manager here
1:32
So let me just go to the files here. And let's click on file manager
1:37
And let's click on access file manager here. Now here you need to go to the public underscore html folder here
1:44
And you have to find the wpconfig.psv file. Just right click on it and first download a copy of this file
1:52
So that if you do any mistake you can easily restore it by copy and paste all content in
1:58
the wpconfig.psv file. So let's double click on it. And as you can see that this is the database wpconfig file looks like
2:08
And here you need to check the database name here. So this is the database name
2:13
So you have to match it with your copied one. So as you can see that the database user name is properly matched
2:20
And then you have to check the database user name. So this is the user name
2:25
And as you can see that the database user name is also perfect. And we have the database password
2:31
Suppose this one is wrong. So let me delete this database name here
2:37
Let me delete this something from the database user. And let me save the file here
2:43
And let's go to the website and let's refresh this page. And as you can see that the site is still active
2:49
But when you try to login to the backend of this website, it will not open from now
2:55
So let's hit admin here. And as you can see that you will see this error
2:59
Error establishing a database connection. That's because the login credential of database is mismatched
3:05
So for this I need to change the database name and the database user correctly
3:11
So let me quickly copy the database name first. And I will replace the existing name here
3:18
So you have to make the correction here. And let's set the database user name as well
3:30
So whenever you are installing any new WordPress website, make sure to copy the database password
3:35
as well. So that if you have any error in the future, you can easily get the database password
3:43
So as you can see that we have the database name, username and password is corrected properly
3:49
Now let's hit the save button here. Now let's again go to the same website and let me refresh this page
3:57
As you can see that we have successfully connected to our database
4:01
So this is how you can fix this error. And if the database is deleted from your hosting, then also you will see this error
4:08
So let me just create that as well. So let's go to the file manager here
4:13
And let's go to the phpMyAdmin here. And here in the MySQL database section, let me delete this database
4:22
So don't do it in your live site. As you can see that we have now deleted the database here
4:31
And when I try to log in again, it will show a error message like this error establishing
4:36
a database connection. That's because the database is missing from our hosting
4:41
So in that case also you will see this error. So if you have accidentally deleted the database, then you have to restore it from backup
4:50
Otherwise there is no solution for that. So luckily I have the backup on my hosting
4:57
So I can easily restore this database. So for this what I can do is I will go to the backup section here
5:06
And here I am using the hosting or business web hosting plan
5:10
So I have the daily database backup option on. So that it will take the automatic daily database backup and the files backup
5:17
So I can easily restore it. So I will click on this database backup option
5:22
Let's select here. And here I have to choose the right database
5:26
So for this you have to again go to the wp-config.php file
5:31
So you will see the file in the public underscore html of your domain
5:37
So you have to go to the wp-config.php file. And you can check the database
5:43
Here you can see ABIYB. So the database name is this. So I have to select the correct database
5:51
And let's click on show database. And here you need to select the database backup
5:57
So this one is taken today. Or you can restore a database that was taken before the error came
6:06
So here let me choose the database of 3-1-2024. And let's click on restore
6:14
And let's hit the restore button. So it will restore our database in the hosting
6:19
And it will fix that error as well. So it is restoring our database in our hosting
6:24
And once the restore is complete, you will be able to access your admin panel of your
6:29
WordPress website. Alright, as you can see that the database backup is complete
6:34
And when you again go to the database management here, you will see the database here like this
6:41
So let me quickly assign this database to this website. Let's click on assign
6:47
And as you can see that the same database is assigned to our domain
6:52
Now let's access the wp-admin of our website. And as you can see that we have successfully accessed the wp-admin
7:00
And let's click on login here. And let's click on that's correct
7:06
And as you can see that we have successfully logged in to our wp dashboard
7:10
So this is how you can fix the error establishing database connection in your WordPress website
7:16
And if your name server is not properly connected, then you can go to your domain register and
7:21
change the name server properly. And after some time it will start working
7:27
And if the database server is down, then you have to contact your hosting server to fix
7:32
that as well. So I hope you have solved your database connection by following this video
7:38
And if you found this video helpful, then make sure to hit the like button
7:42
And for more videos like this, do subscribe our channel. And I will see you in the next one
7:46
Bye Bye