MySQL troubleshooting and correction process-MySQL

Source: Internet
Author: User
The general process of MySQL fault detection and correction is as follows:

◆ Check tables with errors. If the table check is successful, the task is completed. Otherwise, the database table with errors must be repaired.

◆ Copy the table file before starting the restoration to ensure data security.

◆ Start restoring database tables.

◆ If the restoration fails, recover data from the database backup or update log.

Before using myisamchk or isamchk to check or repair a table, note the following:

◆ Create database backup and use Update logs to prevent repair failures and data loss.

◆ Read this chapter carefully before proceeding with the operation, especially before reading "avoid interacting with MySQL server. Because it may cause serious consequences if you do not have enough knowledge.

◆ If you maintain a table on the Unix platform, you should first register a dedicated account mysql to avoid ownership issues during table read/write access and damage all permissions of the Database Directory.

Database table maintenance tools

MySQL's myisanchk and isamchk utilities are similar, basically they have the same usage method. The type of the table used for the main differences between them. To check/fix MyISAM tables (. MYI and. MYD), you should use the myisamchk utility. To check/repair ISAM tables (. ISM and. ISD), you should use the isamchk utility.

◆ To use any program, specify the table you want to check or repair. the usage of myisamchk and isamchk is as follows:

Shell> myisamchk options tbl_name shell> isamchk options tbl_name
If you want to, you can name several tables in the command line.

◆ You can also specify a name as an index file (". MYI "or". ISM), which allows you to use the mode "*. MYI "or". ISM specifies all tables in a directory. For example, if you are in a database directory, you can check all tables in the directory as follows:

Shell> myisamchk *. MYI shell> isamchk *. ISM
◆ If you are not in the database directory, you can specify the directory path:

Shell> myisamchk options/path/to/database_dir/*. MYI shell> isamchk options/path/to/database_dir/*. ISM
◆ You can even specify a wildcard for the path of the MySQL data directory to act on all tables in all databases:

Shell> myisamchk options/path/to/datadir/*. MYIshell> isamchk options/path/to/database_dir/*. ISM
This method cannot be used on windows.

Note that neither myisamchk nor isamchk can determine the location of the table. Therefore, you should run the program in the directory containing the table file or specify the table path name. This allows you to copy the table file to another directory and use the copy operation.

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.