I have not heard so far in 2015 there was any virus or SQL feat to put it “to the ground” Hundreds of sites and blogs WordPress, as it was in the past years, but about a month weird things appear. I met several sites that seemed to have lost Connection to the database.Error establishing a database connection.
In practice, when such an error appears on WordPress, the first things that are verified are:
- If the service mysql runs on the server. Are situations where of overloading the server on which the database, the service mysql / mysqld not to run. In this case, the service from the terminal (via SSH or console) or from the web interface is restored if there is this possibility.
- Configuration error user / word in wp-config.php. In this situation it is checked if the user database and the database name are correctly set in WP-Config.php.
A third situation is corruption (inexplicable so far) Table wp_options FROM MySQL. So before you panic if you find your site with “Error establishing a database connection”, it is good to check if the tables in the database are okay.
How to check and repair the WP_OPTIONS table in WordPress in case of corrupt. Marked As Crashed and Should Be Repaired.
1. We open phpMyAdmin, we go on the website database that is dropped and try to access the table wp_options. If it is corrupt, an alert will appear that inform us.

In the above screen is about the table wp_options from the database “mobile_apk“. Table ‘sqldb/wp_options’ is marked as crashed and should be repaired.
2. We select the WP_OPTIONS table, ticking the box next to him, then we go to the bottom at the Drop-Down menu (with selected) and select “Repair table“.

3. After this step in the tutorial, wait for the answer to the SQL command and then check if the site goes in normal parameters.

WordPress users who do not have PHPMYADMIN installed, can do this from the terminal / server on which the database is executing the orders:
- Check that the WP_OPTIONS table is corrupted:
mysqlcheck -c baza_date wp_options -u user_db -p - Repair the WP_OPTIONS table from the database “base_date”:
mysqlcheck -r mydb wp_options -u user -pIt is good that after you make sure that the site has returned to normal to make a backup at the database. I even recommend the periodic backup. It is never known :)
 
			
WHY does this happen, though? I’ve been experiencing this with multiple sites for a client that are all hosted on a Godaddy server. Fixing it is easy enough, but what makes it corrupt in the first place and how do I prevent it from happening again?