Created
October 13, 2015 03:31
-
-
Save tony4d/75d3246592dcbeb389a6 to your computer and use it in GitHub Desktop.
Analyze all tables in a mysql database from the command line (bash)
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 | |
# 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 | |
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
Hello,
With MySQL 5.5 and above, we can use:
mysqlanalyze --login-path=mylogins --databases database_names
Regards,
Harsha