Skip to content

Instantly share code, notes, and snippets.

@yoku0825
Forked from doublemarket/loadcache.sh
Last active December 15, 2015 20:19
Show Gist options
  • Save yoku0825/5317427 to your computer and use it in GitHub Desktop.
Save yoku0825/5317427 to your computer and use it in GitHub Desktop.
#!/bin/sh
CMDNAME=$0
if [ $# -le 0 ] ;then
echo "Usage: $CMDNAME database database ..."
fi
shift `expr $OPTIND - 1`
for database in $@ ;do
tables=`mysql -uroot information_schema -sse "SELECT table_name FROM tables WHERE table_schema = '$database' AND engine = 'MyISAM'"`
for table in $tables ;do
echo "`date` LOAD INDEX INTO CACHE $table"
mysql -uroot $database -e "LOAD INDEX INTO CACHE $table"
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment