I wrote a little script that will defragment fragmented tables. You can supply usernames and passwords, and even run it against remote MySQL databases.
Here’s an example of it’s output:
root@lit [~]# mysqlFragFinder.sh
MySQL fragmentation finder (and fixer) v1.0.0
Written by Phil Dufault (firstname.lastname@example.org, http://www.dufault.info)
Found 2 databases
Checking dufault_blog ... found 6 fragmented tables.
Optimizing wp_commentmeta ... done
Optimizing wp_comments ... done
Optimizing wp_options ... done
Optimizing wp_postmeta ... done
Optimizing wp_term_relationships ... done
Optimizing wp_users ... done
6 tables were fragmented, and were optimized.
I find this a great script — maybe a feature to add later is a way to prevent it from optimizing really large tables.
The source code is now hosted on GitHub!
Here’s a link to it:
Any other features you’d like to see in it? Comment! Patches welcome.