WebHosting Blog

« Creating Your Own Server Stat Script in PHP | Home | List of Open Source Content Management System »

Method to repair the corrupt MySQL tables

By bob | March 28, 2008

Since, MySQL tables have a way of corrupting themselves. However MySQL offers a quick and easy method of repairing those tables.

Check how  you can repair the corrupt MySQL tables;

Login to your VDS via SSH and change directories to the database that is having problems.

cd /usr/local/mysql/var/[DBNAME]/

You will need to replace [DBNAME] with the actual name of your database.

Stop the MySQL server:

/etc/rc.d/init.d/mysql stop

NOTE: Accounts created before July 7th, 2003 will want to use:

/etc/rc.d/init.d/mysqld stop

To check the tables:

myisamchk *.MYI

To repair tables:

myisamchk -r *.MYI

Restart MySQL:

/etc/rc.d/init.d/mysql start

NOTE: Accounts created before July 7th, 2003 will want to use:

/etc/rc.d/init.d/mysqld start

Alternatively, if you do not want to shut down MySQL, you can use mysqlcheck.

mysqlcheck [DBNAME]

To repair the database tables:

mysqlcheck -r [DBNAME]

You will need to replace [DBNAME] with the actual name of your database.

For additional help and documentation you can check here:
http://dev.mysql.com/doc/mysql/en/Table_maintenance.html
http://dev.mysql.com/doc/mysql/en/Using_mysqlcheck.html

Topics: Hosting Tools |

Comments