Repairing MYSQL database after a crash


If you find this free website useful – why don’t you support this with a donation? It is easy…. read more ….

With linux, its a good idea to monitor your disc space carefully as if you run out of space you can create all sorts of problem.  Elsewhere I will post a disc space usage script that you might find useful.

So you had a crash due to lack of space it is highly likely that if you are running an active LAMP server you will have ended up with corrupted database tables. These need to be fixed.

These can be fixed one by one by going into mysql (using phpmysqladmin if you like) and doing

REPAIR TABLE table_name

However, you probably want to go through all your tables, and indeed if you have multiple databases, all your databases and repair them all.

How to do it is documented here, however the command line command you want is (on one line)

myisamchk --silent --force --fast --update-state --key_buffer_size=64M --sort_buffer_size=64M --read_buffer_size=1M --write_buffer_size=1M  path_to_database_files/*/*.MYI

Of course you need to identify and change  ‘path_to_database_files’ on Centos you will probably find this is  ‘/var/lib/mysql’ so the command line you want for Centos would be

myisamchk --silent --force --fast --update-state --key_buffer_size=64M --sort_buffer_size=64M --read_buffer_size=1M --write_buffer_size=1M  /var/lib/mysql/*/*.MYI

, ,

Leave a Reply

Your email address will not be published.