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 server 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
|
|
|
|
|
|
Related posts:
- How To Set Up A Load-Balanced MySQL Cluster With MySQL 5.1 This tutorial is based on Falko Timme’s tutorial for MySQL...
- Linux Server Type: Restoring MySQL SimLink. If you’re unable to restart mysqld and troubleshooting the cause:...
- Taking backup of mysql database using cron Taking backup of mysql database using cron Create a file...
- Turbo charging MySQL by setting up the query cache To make sure MySQL uses the query cache, there are...
- Moving mySQL DBs between servers Moving mySQL DBs from one server to another: mysqldump -uUSER...
