Web Hosting Talk







View Full Version : Repairing an entire MySQL database


Sizzly
07-30-2005, 03:59 AM
I'd like to repair an entire database from SSH. I can get in to mysql and enter commands fine, but all I know how to do is

REPAIR TABLE tablename;

I've tried inserting a wildcard (* or %) for tablename, but it doesn't work.

The reason I want to do this that there is more than one table that needs to be repaired, and I don't want to manually type and repair each one.

myisamchk doesn't seem to work either:

[root@server root]# myisamchk -r /var/lib/mysql/db2/*
-bash: /usr/bin/myisamchk: Argument list too long

Anyone have any ideas or workarounds?

edge100x
07-30-2005, 05:17 AM
Since myisamchk only looks at .MYI files anyhow, you might try this:

myisamchk -r /var/lib/mysql/db2/*.MYI

If that still doesn't work, try calling myisamchk on each individual file:

find /var/lib/mysql/db2 -name *.MYI -exec myisamchk -r {} \;

Burhan
07-30-2005, 07:12 AM
Make sure you shut down the server first before your run myisamchk, otherwise, tables that you are trying to repair may be open and myisamchk will return errors for those tables.