VDS Sphera Knowledge Base

Main / Browse Categories / MySQL / How can I repair corrupt MySQL tables?

Print article Print Article    Email article Email Article

How can I repair corrupt MySQL tables?
Every so often, MySQL tables have a way of corrupting themselves. MySQL offers a quick and painless method of repairing those 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.

You can find additional documentation here:
http://dev.mysql.com/doc/mysql/en/Table_maintenance.html
http://dev.mysql.com/doc/mysql/en/Using_mysqlcheck.html

User Comments
How can I repair corrupt MySQL tables?  
There are no user comments for this topic.
 

Attachments
No attachments.

Related Articles
 How can I connect to MySQL using SSH?
 How can I dump a MySQL database from the command line?
 My Disk Quota is unusually high. What can I do?
 Where is MySQL located?
 Where is the MySQL log file?

Why Choose Our Hosting?

  • Unmatched Customer Support!
  • Virtual Private Server technology provides a rich, dedicated-like environment for every account.
  • We are known for our superb quality, performance and flexible hosting environment. We manage the server, software, and network you do the rest.
Continue reading »

Featured Hosting Plan


Learn more about our VPS Extreme

What is Included?

  • PHP 5/MySQL 5
  • Parallels® Plesk Panel 10
  • Unique IP Address
  • Daily VPS Backups (Off Server)
  • SAS Hardware Raid diskspace
  • CentOS 5 x86_64 bit
  • Multi-homed Tier 1 Bandwidth
  • Full Upgrade capabilities
Continue reading »