Wednesday, March 17, 2010

MySQL Maintenance for MyISAM Tables

Moodle.org recommended performing regular re-indexing of the tables in a Large Moodle Installation. Since my install of Moodle uses the MyISAM storage engine, this will be accomplished using the myisamcheck command.

This will mean stopping the MySQL service whilst the command is running!

0. Login as root on the database server.

1. Stop the Mysql Service
service mysqld stop

2. Run the myisamcheck command
myisamchk --analyze --check --extend-check --force --verbose /var/lib/mysql/yourdatabasename/ *.MYI

3. Start the Mysql Service
 service mysqld start

It is recommended to do this monthly for very large databases with high activity.

-n