For many reasons, including the wrong server configuration and settings and the poor database optimization, the MySQL database in WordPress, and in any other platform can show error like “#145 – Table …” or similar messages like error establishing a database connection.
In the case of the error 145, the messages will be followed by phrases, like:
is marked as crashed and should be repaired.
That shows you the solution from the beginning. You have corrupted database tables and you have to repair them in order to make things work again.
To fix this database table problem, you need to have access to your phpMyAdmin area first, and then, you can follow the following tutorial. But first, make sure that you have at least, one backup of your full website, and database before doing anything. If something wrong happens, you still have the backup to restore the full database.
So, log in to cPanel, first, and then locate the “phpMyAdmin” icon and click on it. Once you’re in phpMyAdmin, click the database name from the left area of the page, and you will get all the tables that are associated with that database. See the next screenshot, as an example to follow.
Now, you will get a successful notification about the tables repair. This will fix the problem in the majority of cases, and you don’t need any additional steps or verification. However, if nothing happens and you still get that error message in MySQL, then, you need to reinstall your database tables manually. It’s not a hard job if you follow my steps.
Make sure you have a backup with your latest posts, and I hope that you will never lose any single word from your work. If you’re using automated daily backup services, for example, you will find your latest backup files. That way you can restore the website as it was exactly.
Once you have the backup file, search for the database, in general, it comes in a compressed file. Then, download it and use your cPanel account to upload that old database, as a restore.
All you have to do is to click the “Backups” icon, next, find “restore a MySQL database” from the left section of the page, and select your file from the local computer. Now, wait for the upload to complete, and you will get a notification about the successful database restore.
Create a user for that database and add all the permissions for it. Now, you need to connect your restored database to WordPress. For this step, open the file “wp-config.php” that you will find in the website root directory.
In the File Manager, open that file end updates your database name, username, and the user password with the new details. Then, save that file and open your blog page to verify.
For a step by step tutorial, read: how to move a WordPress database and also, you can import the WordPress database in phpMyAdmin. It’s another easy step if you can’t use the standard cPanel method for restoring the databases.
Please make sure that you have a compatible version of MySQL. In some rare cases, people find that they are using an outdated version that is not supported by WordPress. Of course, that will cause problems with restoring tables and even repairing them.