Skip to content

Instantly share code, notes, and snippets.

@rluisr
Created May 7, 2021 08:44
Show Gist options
  • Save rluisr/c2aeb937290a9990962e1a210dc85991 to your computer and use it in GitHub Desktop.
Save rluisr/c2aeb937290a9990962e1a210dc85991 to your computer and use it in GitHub Desktop.
Analyze all tables on specified db
#!/bin/bash
DB_NAME=( "db1" "db2" )
for db_name in "${DB_NAME[@]}"; do
for table in $( mysql --login-path=luis_ro -D ${db_name} -Bse "show tables" ); do
mysql --login-path=luis_rw -D ${db_name} -Bse "analyze table $table";
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment