We often need to optimize the MySQL database, and cainiao will go to phpMyAdmin one by one.
PHP development is generally implemented in website programs through php, but these two methods are not good enough.
The following is a tip for you: Use mysqlcheck as a command, which is efficient and secure.
Run the following command in putty or crt:
Mysqlcheck-Aao -- auto-repair-u your username-p your password
If nothing happens, you will find that all your databases have been optimized and repaired once!
If mysqlcheck is not found, skip this step.
The reason why mysqlcheck cannot be found is generally compiled and installed manually. Just like me, just locate mysqlcheck and find it under/usr/local/mysql/bin, the path specified when I installed MySQL.
, OK, add a shortcut to him
Ln-s/usr/local/mysql/bin/mysqlcheck/usr/bin/mysqlcheck
The meanings of the following parameters
-A, -- analyze analysis [Analyze given tables]
-O, -- optimize optimization [Optimize table]
-A, -- all-databases all databases [Check all the database]
-- Auto-repair Automatic repair [If a checked table is already upted, automatically fix it. Repairing will be done after all tables have been
Okay. Add it to the cron job and execute it automatically at every day.
Crontab-e
0 1 *** mysqlcheck-Aao-auto-repair-u your username-p your password>/dev/null 2> & 1