Optimize mysql databases on a regular basis in Linux

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.