Skip to content

Instantly share code, notes, and snippets.

@tjnh05
Forked from tony4d/mysql-analyze-all-tables.sh
Last active June 15, 2021 06:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tjnh05/b3a1a09db9f3d576caae599cfcb6cb42 to your computer and use it in GitHub Desktop.
Save tjnh05/b3a1a09db9f3d576caae599cfcb6cb42 to your computer and use it in GitHub Desktop.
Analyze all tables in a mysql database from the command line (bash)
#!/bin/bash
# To avoid doing things like putting your mysql password on the cli which is not secure
# Use mysql config editor http://dev.mysql.com/doc/refman/5.6/en/mysql-config-editor.html
database_name=ifrs17_per_biz2
for table in $(mysql --login-path=mylogins -D $database_name -Bse "show tables");
do mysql --login-path=mylogins -D $database_name -Bse "analyze table $table";
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment