Correct repair scheme for MYSQL data table damage _mysql

Source: Internet
Author: User
It is a common problem to have a database error with MySQL (the best combination of PHP) with a power outage or an abnormal shutdown. There are two ways, one way to use the SQL statements of Check table and repair table for MySQL (and the best combination of PHP), and the other is to use the multiple myisamchk provided by MySQL (and the best combination of PHP) Isamchk Data detection and recovery tool. The former is relatively simple to use. Recommended use.

1. Check table and Repair table

Login MySQL (best combination with PHP) Terminal:

MySQL (best combination with PHP)-uxxxxx-p dbname

1.> Check table tabtest;

If the results say that the status is OK, then do not repair, if there is error, you can use:

1.> Repair table tabtest;

Repair and can be checked with the check Table command after repair. The Check/repair feature can also be used in the new version of phpMyAdmin.

2. Myisamchk, Isamchk

Where Myisamchk applies to myisam types of data tables, ISAMCHK to ISAM types of data tables. The main parameters of these two commands are the same, and generally the new system uses MyISAM as the default datasheet type, which is illustrated with Myisamchk as an example. When you find a problem with a data table, you can use:

1.MYISAMCHK TableName. Myi

For testing, if you need to fix it, you can use:

1.MYISAMCHK-OF TableName. Myi

For a detailed parameter description of MYISAMCHK, see its use help. Note that when making modifications, you must ensure that the MySQL (and the best combination of PHP) server does not have access to the datasheet, and that it is best to shutdown the MySQL (and the best combination of PHP) servers when testing.

In addition, you can put the following command in your rc.local to start MySQL (and PHP with the best combination) before the server:

1.[-x/tmp/mysql (the best combination with PHP). Sock] &&/pathtochk/myisamchk-of/data_dir/*/*. Myi

The/tmp/mysql (the best combination of PHP). Sock is the sock file location for MySQL (the best combination of PHP), and for users who use the RPM installation, it should be/var/lib/mysql (the best combination of PHP)/mysql (The best combination with PHP). Sock, the use of source code installation is/tmp/mysql (the best combination with PHP). Sock can be changed according to their actual situation, and Pathtochk is Myisamchk location, Data_ Dir is where your MySQL (and PHP Best Mix) database resides.

Note that if you are going to put this command in your rc.local, you must confirm that the MySQL (and the best combination of PHP) server must not be started when executing this instruction!

Detect repair of all databases (table)

MySQL (best combination with PHP) check-a-o-r-P

The above related content is to repair the corrupted MySQL data sheet introduction, hope you can have some harvest.
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.