Created
March 5, 2018 18:47
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
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
MYSQL_DBS=$(mysql -e "show databases like '${VESTA_USER}_%';" | awk '{ if ($1 != "Database") print $1 }')
=
MYSQL_DBS=$(mysql -e -N "show databases like '${VESTA_USER}_%';"