运行repair时遇myisamchk错误140,如何修复指定MyISAM表?
Got it, let's break down how to fix this error you're seeing: myisamchk: error: 140 when opening MyISAM-table '/var/lib/mysql/zibarsho_karno/wp_yoast_seo_links.MYI'. Error 140 for MyISAM usually means there's a problem with the table files—either corruption, permission issues, or the table was still in use when you tried to repair it. Here's a step-by-step approach to get it sorted:
First, stop the MySQL service
MyISAM tables can't be safely repaired while MySQL is accessing them. Run this command to shut down the service (adjust based on your OS if needed):sudo systemctl stop mysql # Or for older systems: sudo service mysql stopCheck and fix file permissions
Sometimes the MySQL user doesn't have proper access to the table files. First, verify the ownership:sudo ls -l /var/lib/mysql/zibarsho_karno/wp_yoast_seo_links.*You should see the files owned by
mysql:mysql. If not, correct the ownership and permissions:sudo chown mysql:mysql /var/lib/mysql/zibarsho_karno/wp_yoast_seo_links.* sudo chmod 660 /var/lib/mysql/zibarsho_karno/wp_yoast_seo_links.*Run the repair tool (start with basic, then force if needed)
Start with a standard repair to fix minor corruption:myisamchk --repair /var/lib/mysql/zibarsho_karno/wp_yoast_seo_links.MYIIf that fails, use the
--forceflag to do a more aggressive repair (this will rebuild the index file and may discard some damaged data, but it's often the last resort for recoverable tables):myisamchk --repair --force /var/lib/mysql/zibarsho_karno/wp_yoast_seo_links.MYIVerify the repair and restart MySQL
Once the repair finishes, start MySQL back up:sudo systemctl start mysqlThen log into MySQL to confirm the table is working:
mysql -u root -pIn the MySQL shell, run:
USE zibarsho_karno; CHECK TABLE wp_yoast_seo_links;You should see a status of
OKif the repair worked.
Quick Notes
- MyISAM is less robust than InnoDB—if you're regularly hitting table corruption issues, consider migrating this table (and others) to InnoDB for better crash resilience.
- Always back up your table files before running aggressive repairs, just in case something goes wrong.
内容的提问来源于stack exchange,提问作者R Shahpari

