How to repair the \”Error when Establishing a Database Connection\” on WordPress

Most of the time, the database of your website will run quietly in the background, retrieve the request request on demand request requests on demand requests on demand requests on demand requests on demand requests on demand on demand on demand on demand on demand on demand on demand requests on demand on demand. information. But if there is a problem, you may encounter the following warning: \”Error when establishing a database connection.\”

Fortunately, there are many ways to repair this common WordPress error. By solving these possible repair methods, you can return your website as soon as possible.

In this article, we will discuss why your site may be difficult to connect to its underlying MySQL database. Then, we will share seven methods to solve the problem of \”Errors in the establishment database connection\” in WordPress.

What is the problem of \”Effects when establishing a database connection\” (and the reason it happens)

\”Error establishment database connection\” error means that WordPress cannot be connected to the database.

WordPress stores all your website data and content in the database. Every time someone visits your website, the content management system (CMS) is connected to the database and retrieved the necessary information. When you encounter this error, this means that everyone cannot access your website, including administrators and website visitors.

There are many reasons for the difficulty of establishing a connection. This problem may be caused by incorrect database information in the WordPress configuration file or the file damage in the database. If the database server is closed, you may also encounter this news.

Since there are various reasons, there are several solutions. This makes it difficult to solve the database connection error.

How to fix the problem of \”Error Error Database Connection\” in WordPress

\”Effective Error when Establishing a Database Connection\” is one of the most common WordPress errors, and it is not easy to diagnose. In this fault exclusion guide, we will help you find the root cause of the problem, so that your website will return to the right track.

1. Check your database credentials

to be connected to the database. WordPress requires the database name, user name, password and server. These are stored in

wp-config.php , which is the configuration file of your site.

If any of these information is incorrect, then WordPress will not be able to connect to the database. To check these credentials, you need to connect to your server using file transmission protocol (FTP) clients such as Filezilla.

After connecting to your site through FTP, you need to find your configuration file. You usually find it in the root directory of the website, which is usually called

public_html or named after your website. Open this folder and find a file named wp-config.php .

wp-config.php 文件通过 FTP

Then, hold down the Control key to hit this file and select

Open . Filezilla will start it in your computer’s default text editor.

MySQL setting part contains the credentials used by WordPress when trying to access your database. To check whether this information is correct, you need to log in to your host panel. The position of this information will vary from your provider, but please note that it is marked as

database or mysql .

Then check whether the database name, user name, password and host are stored in

WP -Config.php

information matching. If there are differences, you need to update the configuration file. In your FTP client, hold down Control and click

wp-config.php

and select . Open this file to edit and update your database credentials. After this change, you can drag the modified wp-config.php file to Filezilla to upload it again. 2. Check your database host information

Your MySQL host name defines the hosting position of your database. If you want to connect to the database, you need to use the correct MySQL host name.

Most WordPress custody companies use LocalHost, but some providers host their databases on different servers. This is especially true for the hostpress host.

If you have verified whether your database name, user name and password are correct, then it is worth checking whether you have used the correct database position position Essence This usually requires you to contact your custody company.

Or, you can manually retrieve this information with the PHPMYADMIN tool. If your provider offers CPANEL, you can usually find Phpmyadmin through logging in to your CPANEL dashboard. Then, search

phpmyadmin

option. In PHPMYADMIN, find

database server

block. This will show information about your server settings, including its location. For example, if it lists your server as \”LocalHost Via Unix Socket\”, your server is located in LocalHost. To check this according to your database credentials, use Filezilla to connect to your site and open your

wp-config.php

file. You will find the MySQL host name in the following part:

/** mysql host name* /[ 123] 定义(“DB_HOST”,“本地主机”);

如果这不正确,那么您可以将

wp-config.php

文件下载到本地计算机并在Any compatible text editor updates this information. Then, just upload the edited file to your server again. WordPress should now be able to connect to your server in the right position.

3. Fix the database

Over time, the files in the database may be damaged. Fortunately, WordPress contains a tool, which promises to repair the disrupted database with just one button.

To enable this repair tool, use filezilla to your

wp-config.php

file. Then, you can open it in the text editor and add it:

Define (\u0026#39; wp_allow_repair \u0026#39; True); Save your change and will be modified wp-config.php file uploaded to your server. Next, enter the domain name of your website and add the following content:

/WP-ADMIN/Repair.php

.   

For example, if your website is located

https://www.mysite.com [[ 123], you need to go to https://www.mysite.com/wp-dmin/maint/repair.php. This will start the built -in database repair tool of WordPress.

You can now choose whether to repair or repair

and Optimize your database. Fix your database may improve your website performance, thereby improving your position in the search engine ranking. This is also very helpful for the overall tourist experience. Considering this, we recommend that you choose to repair and optimize the database

. WordPress will now try to repair your database and display a page code after completing the process.

数据库修复向导 As we just saw, the access to the database repair tool is as simple as

wp-add/main/repair.php

to your domain URL. This is a safety risk, so it is important to disable this tool immediately after you perform scanning.

You can use Filezilla to open your wp-config.php

file Delete the \”wp_allow_repair\” line. Then, upload this modified file to your server again. This will disable the database repair tool and close the potential security loopholes.

4. Check whether your database server is offline Sometimes your database server may be closed. In particular, if your website has experienced a period of traffic, this may happen. If you use a shared host or choose a budget -friendly host with limited resources, you also face greater risk of shutdown. If your server is in a departure state, WordPress will not be able to connect to your database, and you will encounter errors.

If you run multiple sites on the same server, it is worthy of your network browserVisit all these sites. If they all show the same database error message, then you will know that this problem has nothing to do with specific websites. In this case, your database server is likely to be in a departure state.

Assuming that you can run multiple sites on the same host account, you can also try Connect to your database via PHPMYADMIN. If you encounter errors or strange behaviors in this tool, it may be the server without response.

If you suspect that your database server is in a departure state, then it is best to contact your hosting service provider. Your network hosting service provider may provide you with the timetable for them to solve this problem. They may not even know that your database is in a departure state.

If you have a special server, a local server or a virtual special server (VPS), you can try to re -start the server manually. This process will be different according to your settings and hosting service providers, so you may need to check the documents of your network custody service provider to obtain more information. Or, if you are not sure how to restart the server, you can contact your provider to seek help at any time.

5. Update your website website

According to reports, some WordPress users pass through Update their WordPress site URL solved the error. You can change this through the PHPMYADMIN tool.

After logging in to the PHPMYADMIN dashboard, select the database that causes the problem. Then, select the

SQL

tab.

You need to enter the name of the table now, which is displayed in the left column of the PHPMYADMIN dashboard. By default, this is usually wp_options .

You can now enter the following MySQL query to ensure that

my_url is replaced with the URL of your WordPress website. You also need to change wp_options

to your own table name:

在 phpMyAdmin 中运行 SQL 查询

update wp_options set option_value \u003d \u0026#39; my_url \u0026#39; where option_name \u003d \u0026#39; siteurl \u0026#39;

After running this query, try to visit your website again. This may have solved your database error.

phpMyAdmin 中的 wp_options 表

6. Check whether your theme or plug -in And the plug -in community is one of the biggest advantages of the platform. Sadly, adding a third -party code to your website may lead to conflict, errors and other strange behaviors.

This code may also be damaged. In particular, if you have recently added some new software, run any update, or edit the code of your website manually, the theme or plug -in may cause database errors.

  Fortunately, there is a simple way to stop all themes and plugins. You can then test whether this solves your database error.  

Use a FTP client like Filezilla to navigate to your

wp-confine

folder. You can then control and click the

plugin directory and select it to rename it. You can use any title, as long as it is not plug -in (for example plugins.bak).

This will be discontinued every plugin on your website. If this solves the error, then you will know that you should blame third -party software. You can now rename this folder to

plugins

to re -activate all plug -ins.

To find out the culprit, please open this folder and rename each plug -in in turn. Once the database disappears, you will successfully identify plugins that cause so many problems.

If each plug -in is not solved, you can use your theme directory to repeat this process. If these techniques cannot solve the problem, then you will know that your third -party software will not cause your database problem. 7. Restore the default WordPress file Core WordPress file may be damaged. In some cases, hackers may try to invade your website by editing WordPress code. Or you may accidentally edit some core files. The plug -in may even modify the WordPress code without knowing it. If this is the case, you can restore the database connection by reinstalling the new version of WordPress.The easiest way is to the clean copy of the corepress core.

通过 FTP 访问的 wp-content 文件夹 Then, decompress the archive and delete

WP-CONTENT

folder. This is crucial because it can ensure that you do not cover all the content with a completely empty directory. You also need to back up your website to ensure that you will not lose any valuable information.

After preparing, drag all fresh WordPress core files into your FTP client. When a prompt appears, choose to cover all previous files.

You can try to visit your site now. If this has solved the error, then the wise approach is to spend some time to browse your website. Installing a new WordPress copy may delete some website modification or settings. In this case, you may need to customize new installation.

How to avoid the problem of \”Errors in the Establishment Database Connection\” in WordPress

Although it is impossible You can minimize the opportunity you encounter this problem.

In some cases, you may need to contact your hosting service provider for help. Here, having a network host with 24/7 customer support or rapid response time will help. This can help you solve errors and let your website recover online quickly.

For this reason, the wise approach is to invest in high -quality custody service providers. They can provide your required professional knowledge and fast turnover time when the database connection is wrong. It is also a good idea to choose a provider specializing in WordPress. These hosts usually optimize their products for the WordPress platform, which can reduce the chance of your database error.

It is also smart to create regular backup. This ensures that you can always choose to restore the early version of the website. According to database errors, this may be enough to solve the problem.

There are many WordPress backup plugins to choose from, but Jetpack Backup can save all your content in real time, including your database. Even if your site is completely closed, you can access and restore backup.

If you noticed the database error message when going out, you can use the Jetpack mobile application to restore backup from your mobile device. Jetpack also creates a redundant copy on multiple servers, so you can be sure that you can restore the working version of the site.

Fix WordPress \”Establishing a database connection error

If you cannot access your WordPress website, then anyone else (including potential customers) cannot be accessed. Therefore, you need to immediately solve the problem of \”errors when establishing database connections\”.

There are many reasons why your site may be difficult to connect to its database, but checking your database credentials (including your host information) is always a good idea. WordPress also includes a built -in database repair tool, which can help helpRestore the damaged database file. If you do encounter this error message, then the recent backup can be a life -saving straw. By installing Jetpack backup on your website. This includes the latest version of your WordPress database.

Author:

Leave a Reply

Your email address will not be published. Required fields are marked *