When you use wordpress, you will surely encounter this error several times, database connection error in wordpress, causing a lot of frustration for the administrator, this error is caused by many different reasons, from data information When it comes to server connection factors, in this post I will share how to fix it Error Establishing a Database Connection in WordPress through a few basic operations.
What is Error Establishing a Database Connection in WordPress?
Error Establishing a Database Connection is also understood as an error connecting to the database in the wordpress website, when the error occurs, there will be a pretty clear message right on the website homepage, you will easily notice this.
People wordpress website design When you encounter this error, you often feel confused and worried, calm down because here is a solution for you.
Error Establishing a Database Connection in wordpress occurs for what reason?
When you see Error Establishing a Database Connection wordpress You need to know right away that the first reason usually causes is that the database parameters in the php configuration are wrong or changed. Located in file wp-config.php in the root directory.
In addition, the Error Establishing a Database Connection error can also be caused by your database server not responding, it may be because your database is corrupted, in my experience, this error occurs mainly because the computer is not responding. server, a few due to wrong database configuration parameters.
Errors showing Error Establishing a Database Connection in wordpress
If the same error message appears on the user page and the admin page, then go to the next step below, and if on the admin page, you see a different error like “One or more tables in the database do not exist. available. The database needs to be edited”, now you need to fix the following:
Add the following code to the wp-config.php file just before the text “That’s all, stop editing! Happy blogging”.
Then you proceed to run this link: http://www.yoursite.com/wp-admin/maint/repair.php (edit yoursite.com to your domain name).
Run and Repair Database to repair corrupted databases.
If it still doesn’t fix the problem then skip to the next step below to find a more effective solution.
Check the database parameters in the file wp-config.php
The wp-config file is very important in configuring the wordpress website, where it connects to the website’s database through parameters such as: database name, user, password, host server.
Pay attention to enter the correct connection parameters, as long as there is one extra or one missing character or space, the error will occur.
Note that DB_Host is not always localhost, mostly localhost, but there are some hosting providers you have to replace with that hosting IP address.
After checking the parameters, if the error is correct, then create a new user and password for this database and then edit these parameters according to the new user and password to check. In my experience, sometimes creating a new one is always error.
Check the website’s server (Mysql server)
Error Establishing a Database Connection In WordPress, it also often happens when the hosting server is too busy to store data or bandwidth, or there are too many accesses at the same time that the server can’t handle it in time, causing errors. I also had this error when there were many visits.
If you use hosting but the website normally has little access but suddenly there are too many visitors at once, it means that your website is under ddos attack, now please send a support request immediately to the hosting provider to handle it. fastest deal.
Refer to how to fix the error of not uploading the theme in wordpress.