Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to repair the damaged MySQL database table

2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly shows you the "MySQL database table damage after how to repair", the content is easy to understand, clear, hope to help you solve doubts, the following let the editor lead you to study and learn "MySQL database table damage after how to repair" this article.

1.MyISAM table corruption use the myisamchk command to repair myisamchk-r-Q followed by your table name. MYI this command is designed to repair myism engine database tables. For example, if your database directory is / var/lib/mysql/db and one of the tables is test, then the method to repair the test table is myisamchk-r-Q / var/lib/mysql/db/test.MYI. If you repair all tables, use this command myisamchk-r-Q / var/lib/mysql/db/*.MYI2.InnoDB table to damage InnoDB has an internal recovery mechanism. If the database crashes, InnoDB runs the log file from the last timestamp. To try to repair the database. In most cases, the repair will be successful, and the whole process is transparent. If InnoDB fails to repair itself, the database will not start. Before continuing, browse the MySQL log file to make sure that the database crashed because of a corruption in the InnoDB table. One way is to update InnoDB's log file counters to skip queries that cause crashes, which will cause data inconsistencies and often interrupt master-slave replication. Once it is determined that MySQL cannot be started because of a corrupted InnoDB table, you can follow the following five steps to fix it: 1. Edit the / etc/my.cnf file and add the following line: innodb_force_recovery = 42. At this point, you can restart the database, in the role of innodb_force_recovery configuration, all insert and update operations will be ignored; 3. Export all data tables; 4. Close the database and delete all data table files and directories, and then run mysql_install_db to create the MySQL default data table; 5. Delete the line innodb_force_recovery in / etc/my.cnf, and then start MySQL (when MySQL starts normally); 6. Recover all data from the files backed up in step 3. Innodb_force_recovery can be set to 1-6, and large numbers contain the effects of all previous numbers. When the setting parameter value is greater than 0, you can select,create,drop the table, but operations such as insert,update or delete are not allowed. 1 (SRV_FORCE_IGNORE_CORRUPT): ignore checked corrupt pages. 2 (SRV_FORCE_NO_BACKGROUND): blocking the running of the main thread, if the main thread needs to perform full purge operations, will result in crash. 3 (SRV_FORCE_NO_TRX_UNDO): no transaction rollback operation is performed. 4 (SRV_FORCE_NO_IBUF_MERGE): merge operations that insert buffers are not performed. 5 (SRV_FORCE_NO_UNDO_LOG_SCAN): without viewing the redo log, the InnoDB storage engine treats uncommitted transactions as committed. 6 (SRV_FORCE_NO_LOG_REDO): roll forward is not performed. The above is all the contents of the article "how to repair a damaged MySQL database table". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report