Repair and Optimize MySQL Databases

Mar 20, 2022 · 1 min read · Post a comment
Repair and Optimize MySQL Databases

In some of the previous posts, I’ve explained how to check if the mysql tables are corrupted. So this topic will shed some light on how to auto-repair and optimize all mysql databases and get rid of the corrupted tables.


  • MySQL
  • MariaDB

Repair and Optimize MySQL databases

Step 1. To auto-repair all mysql databases, run:

sudo mysqlcheck --check --auto-repair --all-databases

Step 2. Once the repair is done, optimize the databases.

sudo mysqlcheck --optimize --all-databases

Step 3. Restart the mysql service.

Debian based:

sudo systemctl restart mysql

RHEL based:

sudo systemctl restart mysqld


Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.