Skip to content

Instantly share code, notes, and snippets.

@lord-alfred
Created March 5, 2018 18:47
Show Gist options
  • Save lord-alfred/0a7c4bbae04424413ef3d5fc453f286d to your computer and use it in GitHub Desktop.
Save lord-alfred/0a7c4bbae04424413ef3d5fc453f286d to your computer and use it in GitHub Desktop.
Optimize all tables in all MySQL databases for VestaCP user (for better performance in InnoDB engine)
#!/bin/bash
# Optimize all tables in all MySQL databases for VestaCP user (for better performance in InnoDB engine)
# set 'chmod +x'
# and add this script in your weekly cron
VESTA_USER="vestacp_username"
MYSQL_DBS=$(mysql -e "show databases like '${VESTA_USER}_%';" | awk '{ if ($1 != "Database") print $1 }')
for DB in $MYSQL_DBS; do
# echo "[$DB]"
mysqlcheck -o $DB
done
@lord-alfred
Copy link
Author

No, as far as I remember there was something else besides these lines :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment