File: //scripts/fixAllMySQL.sh
#!/bin/bash
DB_LIST="/scripts/database.list"
mysql -u root -e 'show databases' | tr -d '|' | grep -v "mysql\|performance_schema\|cyberpanel\|information_schema" > $DB_LIST
cat $DB_LIST | while read DB
do
echo "Processing DB: $DB"
OPTION_TABLE=`mysql -u root "$DB" -e 'show tables'|grep "options"`
mysql -u root "$DB" -e 'OPTIMIZE TABLE `'$OPTION_TABLE'`; '
CONFIG_TABLE=`mysql -u root "$DB" -e 'show tables'|grep "config"`
mysql -u root "$DB" -e 'OPTIMIZE TABLE `'$CONFIG_TABLE'`; '
done