MYsql - How to check mysql database and how to repair it ?

Started by Dipak Bhoi, January 11, 2014, 11:29:54 PM

Previous topic - Next topic

Dipak Bhoi

Hello,

I am new for linux hosting and want to know how to check MySQL database and how to repair it, if there is a problem in database.

If you have a same question in your mind then you are on correct forum. Below are the command which help you to check database and also repair it. Login into your server via ssh as a root user and performed following things.

To check the database run the command as below.

Quote# mysqlcheck database_name

databse_name.table_name                          OK
databse_name.table_name                          OK
databse_name.table_name                          OK
databse_name.table_name                          OK
databse_name.table_name                          OK
databse_name.table_name                          OK
databse_name.table_name                          OK
databse_name.table_name                          OK

If you receive the output as above then there is everything is well in your database. If you get the output as below.

Quotedatabse_name.table_name                          OK
databse_name.table_name                          OK
databse_name.table_name                          OK
databse_name.table_name                          OK
databse_name.databse_name
warning  : Table is marked as crashed
Above output is showing there is a table which has been crashed, you will have to repair it by running following given command.

Quote#myisamchk -r -f databse_name/databse_name.MYI

QuoteData records: 346
- Fixing index 1
- Fixing index 2
- Fixing index 3
- Fixing index 4
- Fixing index 5
- Fixing index 6

This command will fix the corrupt table, once they are repaired you can re-check your database by running mysqlcheck command.
MilesWeb - 30-Day Money Back
cPanel Web Hosting - cPanel Hosting in India
Grab a Free SSL for your website.  WordPress Optimized Solution.