Repair all mysql tables (and check and optimize them) in one command

Hello everyone.

I need repair all mysql tables of database db_test (and check and optimize them) in one command and I try this:


CHECK table db_test._temp_tbl; 
 REPAIR table db_test._temp_tbl;
 OPTIMIZE table db_test._temp_tbl;

—Working


CHECK tables db_test.*;
 REPAIR tables db_test.*;
 OPTIMIZE tables db_test.*;

—Not working: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘*’ at line 1


CHECK all tables db_test;
 REPAIR all tables db_test;
 OPTIMIZE all tables db_test;

—Not working: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘all tables db_test’ at line 1

Can you help me?

two questions

  1. why do you need to do this to all your tables?

  2. why in one command?

Because some tables crashed…

Just an idea, if you have other solution it’s ok…

then wouldn’t it make sense to repair only those tables?

if you’re going to invest effort, my advice is to apply it to finding out ~why~ some tables crashed, and fix whatever is causing it

I understand your suggestion, but I have problem: I am not a database db_test administrator and I’m not a writer tables.

When error web I found the problem with tables crash.

Only option is to work with server-language and SQL try to repair tables.