Mysql: Repair all tables in a database with a couple of commands in Linux
The process is fairly simple. If you have dozens or hundreds of tables, it can be a hassle to repair them in phpmyadmin. Using a couple of shell commands, you can accomplish this repair task easily in a matter of seconds.
In the following examples, “portalwebmx” is the database name.
1. Obtain a list of all the tables
[root@projectivemotion ~]# mysql -B -e 'show tables;' portalwebmx > tables.txt
2. Execute the repair command for each table.
[root@projectivemotion ~]# for e in `cat tables.txt`; do mysql -e "repair table $e;" portalwebmx; done;