mysql修复表命令

发布时间: 2023-11-21 12:11 阅读: 文章来源:1MUMB3239PS

工作中会遇到网站访问提示mysql错误:Table XXX is marked as crashed and should be repaired。除了可以通过安装phpmyadmin进行修复,还可以通过mysqlcheak命令进行修复。

1、修复某个数据库所有表

mysqlcheck-r-uroot -pdbname

2、修复指定表

mysqlcheck-r-uroot -pdbnametablename

3、修复所有数据库表

mysqlcheck -A -o -r -p -uroot -p

4、自动检查、优化修复、分析所有表

mysqlcheck -Aao --auto-repair -uroot -p

5、myisamchk 修复表

myisamchk -r 数据文件目录/数据表名.MYImyisamchk -r /www/wdlinux/mysql/var/*/*.MYI #如数据库表比较大修复失败,可加--sort_buffer_size=2Gmyisamchk -r /www/wdlinux/mysql/var/*/*.MYI --sort_buffer_size=2G

6、mysqlcheck 常用选项

-A, –all-databases 表示所有库-a, –analyze 分析表-o, –optimize 优化表-r, –repair 修复表错误-c, –check 检查表是否出错–auto-repair 自动修复损坏的表-B, –databases 选择多个库-1, –all-in-1 Use one query per database with tables listed in a comma separated way-C, –check-only-changed 检查表最后一次检查之后的变动-g, –check-upgrade Check for version dependent changes in the tables-F, –fast Check tables that are not closed properly–fix-db-names Fix DB names–fix-table-names Fix table names-f, –force Continue even when there is an error-e, –extended Perform extended check on a table. This will take a long time to execute.-m, –medium-check Faster than extended check option, but does most checks-q, –quick Faster than medium check option
•••展开全文