How to repair a corrupted MySQL data sheet

Source: Internet
Author: User

id=164 the MySQL database error is a very common problem due to a power outage or an abnormal shutdown. There are two ways to use MySQL's check table and Repair table SQL statement, and the other is to use the multiple myisamchk provided by MySQL to isamchk the data detection recovery tool. The former is relatively simple to use. Recommended use.
1. Check table and Repair table
Log in to MySQL terminal:
Mysql-uxxxxx-p dbname
> Check table tabtest;
If the result says status is OK, then do not repair, if there is error, you can use:
> Repair table tabtest;
Fixed and can be checked using the Check Table command after the repair. You can also use the Check/repair feature in the new version of phpMyAdmin.
2. Myisamchk, Isamchk
Where myisamchk applies to data tables of the MyISAM type, and ISAMCHK applies to data tables of the ISAM type. The main parameters of these two commands are the same, and generally the new system uses MyISAM as the default data table type, which is illustrated with Myisamchk as an example. When you find a problem with a data table, you can use:
MYISAMCHK TableName. MYI
For testing, if needed, you can use:
MYISAMCHK-OF TableName. MYI
For a detailed parameter description of the MYISAMCHK, refer to its use Help. Note that when making modifications, you must make sure that the MySQL server does not have access to the data sheet, and that it is best to shutdown the MySQL server in case of an inspection.
-----------------------------
Alternatively, you can put the following command in your rc.local before starting the MySQL server:
[-x/tmp/mysql.sock] &&/pathtochk/myisamchk-of/data_dir/*/*. MYI
The/tmp/mysql.sock is the sock file location of the MySQL listener, for users who use RPM installation should be/var/lib/mysql/mysql.sock, for the use of the source installation is/tmp/ Mysql.sock can be changed according to their actual situation, and Pathtochk is Myisamchk location, Data_dir is your MySQL database storage location.
Note that if you intend to place this command in your rc.local, you must confirm that the MySQL server must not be started when executing this instruction! Detect and repair all databases (tables)

How to repair a corrupted MySQL data sheet

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.