Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Analyze all tables in a mysql database from the command line (bash)
# To avoid doing things like putting your mysql password on the cli which is not secure
# Use mysql config editor
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";

This comment has been minimized.

Copy link

@hnhegde hnhegde commented Nov 18, 2017

With MySQL 5.5 and above, we can use:
mysqlanalyze --login-path=mylogins --databases database_names


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