Latest News

Optimizing and Repairing MySQL Databases with mysqlcheck

  • Ivan Ivanov
  • MySQL
Optimizing and Repairing MySQL Databases with mysqlcheck

MySQL Tables can crash quite easily, especially when your server unexpectedly shuts down or crashed, or when you're forced to copy data around when it's still being accessed.

Luckily, there's a simple command to automatically check, repair and optimize all tables in all databases when you're running a MySQL Server on Linux / Unix / BSD.


In /etc/crontab we add the below two lines which will run every sixth and seventh hour and there won't be a need for us executing them manually.


0 */6 * * * root /usr/bin/mysqlcheck --optimize --all-databases >/dev/null 2>&1
0 */7 * * * root /usr/bin/mysqlcheck --auto-repair --check --all-databases >/dev/null 2>&1

49 seconds