MySQL implementation of MYISAM table batch compression _ MySQL

Source: Internet
Author: User
This article describes how to implement MySQL batch compression for MYISAM tables. The example shows how MySQL uses shell commands to batch compress MYISAM tables, for more information about MySQL batch compression, see the following example. We will share this with you for your reference. The details are as follows:

For compression of MYISAM tables, you can use myisampack and myisamchk (myisamchk must be used after myisampack to use the compressed table, and it is read-only ), for detailed usage, refer to the official documentation:
Http://dev.mysql.com/doc/refman/5.1/zh/client-side-scripts.html.

These two operations need to be used with caution. before compression, you need to confirm that mysqld is disabled or that the table to be compressed does not have any other SQL operations, and the compression process will occupy cpu resources, we recommend that you do this when the server is idle.

The following is the shell process used to compress the following table of a database (it is worth noting that if the data volume is large, we recommend that you perform the operation multiple times because it takes a lot of time ):

#! /Bin/bashdata_dir = "/data/mysql/my_dbname/" filelist = 'ls $ data_dir 'echo "myisampack begin. "for filename in $ filelistdo idx = 'expr match" $ filename "". *. MYI "'if [[$ idx> 0] then/usr/bin/myisampack $ data_dir $ filename fidoneecho" MYISAMPACK End. myisamchk begin. "for filename in $ filelistdo idx = 'expr match" $ filename "". *. MYI "'if [[$ idx> 0] then/usr/bin/myisamchk-r-o-f -- sort-index -- analyze $ data_dir $ filename fidoneecho" myisamchk end."

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.