A database error occurred? See what could have happened and how to fix it


A database error occurred? See what could have happened and how to fix it
2018-06-10
A database error can be really frustrating for WordPress users. Especially, that it can occur on its own without you changing anything on your page. Check out why the database error occurred and how to fix it.

 

What is a database error?

If you try to enter your page’s URL, but you see nothing except a message Error establishing a database connection, you will have to handle a database error. It may appear as a result of a great variety of reasons:

  • Your database login credentials are wrong.

  • Your database server is unresponsive.

  • Your database has been corrupted.


How to identify and fix the bug step by step

To fix a database connection error, use an HTML website help in 3 steps:

  1. Check if a database error occurred also at the back-end

If the database connection error – Error establishing a database connection – occurs also for /wp-admin/, you can go to the step number 2. However, if you see a different message under the /wp-admin/, then you need to repair your database. Go to wp-config.php and add the following line:

define('WP_ALLOW_REPAIR', true);

just before:

That’s all, stop editing! Happy blogging.

Then, visit the page http://www.yoursite.com/wp-admin/maint/repair.php under which you will find two options: Repair Database and Repair and Optimize Database. Click on the further option. Once you are done repairing your database, remember to remove this line – define('WP_ALLOW_REPAIR', true); – from your wp-config.php. Sometimes repairing the database is enough to fix the database error. If not, keep reading.

2. Check data under your wp-config.php

It may happen that you changed your root password or database password, but they stayed unchanged under wp-config.php. So, check the following lines to make sure all data is updated:

define('DB_NAME', 'database-name');

define('DB_USER', 'database-username');

define('DB_PASSWORD', 'database-password');

define('DB_HOST', 'localhost');

Sometimes it helps to insert your IP number under the ‘localhost’. If all data is all right, but the database error is still a problem, keep digging.

3. Check the MySQL server

The reason for a database error may be that a PHP code cannot connect to MySQL to read out the information needed to fully build the page. To check the problem on your own:

  • Go to phpMyAdmin.

  • Create a new file called testconnection.php.

  • Paste there the following code making sure all data is correct:

<?php

$link = mysql_connect('localhost', 'root', 'password');

if (!$link) {

die('Could not connect: ' . mysql_error());

}

echo 'Connected successfully';

mysql_close($link);

?>

If you cannot connect to the server, you can assume that it is MySQL posing a problem. Possibly, the user does not have a sufficient permission. At this point, you should contact your host to ask for fixing it.



Redakcja Archnews informuje, że artykuły, fotografie i komentarze publikowane są przez użytkowników "Serwisów skupionych w Grupie Kafito". Publikowane materiały i wypowiedzi są ich własnością i ich prywatnymi opiniami. Redakcja Archnews nie ponosi odpowiedzialności za ich treść.

Nadesłał:

HTML help
http://fixmakers.com/

Wasze komentarze (0):


Twój podpis:
System komentarzy dostarcza serwis eGadki.pl