Error connecting to database: reason, correction

When developing our own site, we often encounter errors in establishing a connection to the database, internal server problems, etc. All this frighteningly affects the beginner. Even experienced bloggers can hardly cope with similar problems. But do not panic. More often, such problems are solved in two ways.

Wordpress

One of the most popular control systems for the "stuffing" of the resource. Small blogs and large projects appear on the WordPress platform. An error connecting to the database occurs precisely with this CMS.

error connecting to database

Written by WP in a general-purpose scripting language PHP. The database server ( database) is MySQL. The first CMS appeared in 2003 and now has version 4.8.1. The advantages of WordPress are the ease of content management, a large number of additional tools - themes and plugins.

Content

Before you understand how to get rid of a connection error with a WordPress database, it is important to consider the structure of the system. Any resource based on this CMS is based on two important elements. We are talking about program files and databases.

The first are located on the hosting, where you can get on request via FTP. The second are hosted in a separate sector. To go, you need to download a special service. PhpMyAdmin is popular.

If program documents need additional information, they go to the database using materials from there. Next, display the resource page correctly.

For the storage path to be correct, access is needed. It means the username and cipher that were set during the initial configuration of the resource. This information is stored in the main folder of the resource.

connection error with wordpress database

If an error is detected in establishing a connection to the database, it becomes clear that program documents do not have the opportunity to get into the database and display the page correctly.

Check

Before solving this problem, you need to carry out a couple of verification steps that will help identify the cause of the error.

First you’ll have to check if there is a database at all. To do this, just go to the panel on which there are tools for hosting management. Everyone has access to it if hosting is purchased. Next, go to the menu with the storage section. In the panel, this item is called “Database”. It is enough to go here and make sure that it is not empty.

If you see that there is a set of files or a folder, then we check to see if it is full: are there additional records, tables, and other materials in it. The database may be empty and does not contain additional information. To verify this, we perform the actions that make the program files.

We use the PhpMyAdmin service, enter the login and password. If you cannot determine if the base is empty, look at its weight and contents. Usually there should be tables and records, and the folder size can be from Kb.

The above process may indicate the following error to you. When entering the login and password, I can’t enter the repository. You may be entering incorrect data or you may have changed them and forgotten. Check if you have switched the language and entered the cipher in other letters. Then try to return to the storage setup and choose a different password. Do not forget to change it in the configuration document.

connection error with denwer database

Why?

Interestingly, an error connecting to the database appears along with the transportation of the resource. And there is a problem with a probability of 99%. If the resource has already been installed on the hosting, and the problem arose, then there may be a number of other reasons.

For example, they deleted the user under whose name the connection was made, changed the cipher, or MySQL was sent to a special server. It happens that the problem arises not because of your fault, but because of the hoster. In this case, it is enough to write to him and report a problem. He will also provide additional information and indicate a solution.

Partial problem

Sometimes a similar nuisance arises partially. Certain tables are missing or inaccessible in the storage. To verify the accuracy of this problem, just go to the admin panel. If the problem recurs, you need to check the database.

To restore it, go to the wp-config.php file. Here you need to add an additional command: define ('WP_ALLOW_REPAIR', true) ;. Now you need to go to the special menu site.com/wp-admin/maint/repair.php. On site.com indicate your resource. After that, a recovery window will appear.

It is advisable to choose in it not just recovery, but also optimization. The process takes several minutes. After completion, you will need to remove the command from the wp-config.php file.

Transportation

You may have decided to move your blog from Denwer over time. An error connecting to the database appears when the wp-config.php file is incorrect. Here you need to specify the configuration needed to connect to the database.

timeweb error connecting to database

Opening this document, it is important to carefully look at the indicators that are available there. Most often, the username and database are the same. It appears when registering on a hosting. There is also a password. All this needs to be preserved when transferring a resource from different services, including Openserver.

The error in establishing a connection to the database is excluded if all personal data you save forever. It is also important not to confuse the database password and the “admin panel”. You also install them separately, and it is desirable that they be different.

Test

If everything is correct, and the error is still not fixed, you need to test the database. For this, a special test file is created. Its configuration may vary slightly, so it is advisable to choose the teams for yourself. Such test.php will help us run a system check.

After you fill out the document, go to site.com/test.php. With a successful connection, it becomes clear that the hosting is working correctly. Likewise, everything is fine with the password and username.

openserver error connecting to database

If the test shows that you are using the wrong name or cipher, then you have to go to the panel and change the data. If you couldn’t get connected at all, then the problem is on the server. Here the matter is simpler. Wait a while or contact your hosting support.

conclusions

Similar problems happen with many hosters, including Timeweb. An error in establishing a connection to the database can also be caused by interruptions on the server, or it may be associated with incorrect user contact. Therefore, if you decide to transfer your blog from a local computer or service to hosting, carefully register all the data that you enter during registration so that you do not have to restore it afterwards.

Source: https://habr.com/ru/post/A957/


All Articles