Rebuilding or Repairing MySQL Tables or Indexes

According to https://dev.mysql.com/doc/refman/5.7/en/rebuilding-tables.html,
Methods for rebuilding a table include:
Dump and Reload MethodALTER TABLE MethodREPAIR TABLE Method
Alter table is preferred way.
Unless you cannot succeed with "alter table" method, then you choose the other way.

Alter table itself won't lock the database from version 5.7. If the database is locked when you run it, it is because you have other queries running that needs the lock. You can interrupt "alter table" and check those locks.

Once you solve those locks, you should be able to run "alter table" without locking the database.

Comments

Popular posts from this blog

Check MySQL query history from command line