Ottimizzare tutte le tabelle in un database MySQL

From RVM Wiki
Jump to navigation Jump to search
  • Usare lo script
#!/bin/bash
for table in $(mysql -u root -proot_pwd -sss -e "select concat(table_schema,'.',table_name) from information_schema.tables where table_schema in ('mydatabasename') order by data_free desc;")
do
  echo OPTIMIZE $table
  mysql -u root -proot_pwd -e "OPTIMIZE TABLE $table;"
done