How to recycle a fragment of a MySQL table

Source: Internet
Author: User
Tags flush

Because the operator a large number of deleted relationship table data up to 20 million rows, but MySQL does not automatically reclaim space, so decided to do defragmentation (first Test):

Myisamchk-r relationship

Under the MySQL run, the results of the query when the following problems appear:

Error 1030 (00000): Got error 127 from table handler

This question is very depressed, should not have the problem, then looked up the data to discover the question:

If you run mysqld with--skip-locking (it is default on some systems, such as Linux), when

When MYSQLD is using the same table, you cannot reliably use MYISAMCHK to check a table. If you can

Sure no one is accessing the table through MYSQLD while you're running Myisamchk, before you start checking the table,

You only need to do mysqladmin flush-tables. If you can't guarantee, then when you check the table, you will

Must stop mysqld. If you run Myisamchk when mysqld is updating the table, you may get a table

Had destroyed the warning, even if it had not.

If you are not using--skip-locking, you can use the Myisamchk checklist at any time. When you do this

, all customers attempting to update the table will wait until MYISAMCHK is ready before continuing.

If you use the Myisamchk fix or optimize the table, you must always ensure that the MYSQLD server is not using the table (such as

You are using--skip-locking, which is also applicable). If you keep dropping mysqld, running in your

Before Myisamchk, you should at least make a mysqladmin flush-tables.

And my database happens to be under Linux, and is skip-locking started, there is this problem!

1 This command can also stop MySQL and then do, it will not appear this problem

2) can also be done online after the restart of the database

3) You can also run Mysqladmin flush-tables before you execute this command, and this problem will not occur!

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.