解决MySQL Table '***' is marked as crashed and should be repaired问题

昨天后端程序在读取数据库信息时候,日志报相关数据表不能读取和写入数据,进入 MySQL数据库发现 Table ‘./wordpress/wp_posts’ is marked as
crashed and should be repaired 错误,因为qqtexas中有数据表被损坏了,所以读取不了数据:

# mysql -u root -p
Enter password:

mysql> use qqtexas;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select * from wp_posts;
ERROR 145 (HY000): Table ‘./wordpress/wp_posts‘ is marked as crashed and should be repaired
mysql> quit

方法一:

修复 MySQL 数据库数据表问题可以由 mysqlcheck 来解决,先用 mysqlcheck 查看一下:

# mysqlcheck -u root -p qqtexas
Enter password:

然后添加 --auto-repair 参数自动修复,最好修复前备份一下数据库:

# mysqldump -u root -p qqtexas > qqtexas.sql
Enter password:

# mysqlcheck -u root -p qqtexas --auto-repair
Enter password:
wordpress.wp_term_taxonomy
error    : Table upgrade required. Please do "REPAIR TABLE `wp_term_taxonomy`" or dump/reload to fix it!
wordpress.wp_terms
error    : Table upgrade required. Please do "REPAIR TABLE `wp_terms`" or dump/reload to fix it!
wordpress.wp_usermeta
error    : Table upgrade required. Please do "REPAIR TABLE `wp_usermeta`" or dump/reload to fix it!
wordpress.wp_users
error    : Table upgrade required. Please do "REPAIR TABLE `wp_users`" or dump/reload to fix it!

Repairing tables
qqtexas.wp_commentmeta                       OK
qqtexas.wp_comments                          OK
qqtexas.wp_links                             OK
qqtexas.wp_options                           OK
qqtexas.wp_postmeta                          OK

为了安全起见,以下两种方法不建议在生产环境中使用
#mysqlcheck -a -o -r -p //检查优化并修复所有的数据库
#mysqlcheck -A -o -r 数据库名称 -p //修复指定的数据库

参数含意:
-a = Analyse given tables. //分析数据表
-c = Check table for errors //检查数据库中错误(损坏)的表
-o = Optimise table //优化数据表
-r = Can fix almost anything except unique keys that aren’t unique // 修复损坏的数据表
-m = –medium-check

方法二:

使用命令myisamchk修复数据库的MYI文件

[[email protected] ~]# myisamchk -c -r /usr/local/mysql/data/qqtexas/zt_action.MYI
- recovering (with sort) MyISAM-table ‘/usr/local/mysql/data/qqtexas/zt_action.MYI‘
Data records: 21810
- Fixing index 1
- Fixing index 2

如果上述操作还不行,就使用 -f 强制执行修复;即

myisamchk -c -r -f /usr/local/mysql/data/qqtexas/zt_action.MYI

mysqlcheck说明:
mysqlcheck客户端可以检查和修复MyISAM表。它还可以优化和分析表。

mysqlcheck的功能类似myisamchk,但其工作不同。主要差别是当mysqld服务器在运行时必须使用mysqlcheck,而myisamchk应用于服

务器没有运行时。使用mysqlcheck的好处是不需要停止服务器来检查或修复表。使用myisamchk修复失败是不可逆的。

Mysqlcheck为用户提供了一种方便的使用SQL语句CHECK TABLE、REPAIR TABLE、ANALYZE TABLE和OPTIMIZE TABLE的方式。它确定

在要执行的操作中使用使用哪个语句,然后将语句发送到要执行的服务器上。

参考:http://www.vpsee.com/

http://www.cnblogs.com/zhoujinyi/archive/2013/05/10/3070667.html

http://www.javatang.com/archives/category/database

解决MySQL Table '***' is marked as crashed and should be repaired问题

时间: 2024-08-07 21:46:22

解决MySQL Table '***' is marked as crashed and should be repaired问题的相关文章

Table '.\mysql\proc' is marked as crashed and should be repaired 报错

Table '.\MySQL\proc' is marked as crashed and should be repaired 报错 解决方法: 找到mysql的安装目录的bin/myisamchk工具,在命令行中输入: myisamchk -c -r ../data/mysql/proc.MYI 然后myisamchk 工具会帮助你恢复数据表的索引.重新启动mysql,问题解决. Table '.\mysql\proc' is marked as crashed and should be

Table '' is marked as crashed and should be repaired 解决方法

解决方法: 找到mysql的安装目录的bin/myisamchk工具,在命令行中输入: myisamchk -c -r ../data/mysql/user.MYI 然后myisamchk 工具会帮助你恢复数据表的索引.重新启动mysql,问题解决. Table '' is marked as crashed and should be repaired 解决方法

mysql错误Table ‘./mysql/proc’ is marked as crashed and should be repaired

今天服务器当机了,重启后就发现了如下错误: Table ‘./mysql/proc’ is marked as crashed and should be repaired 解决方法: repair table mysql.proc;

检查和修复mysql表:mysql table is marked as crashed and last (automatic?) repair failed

0x001  问题背景 mysql上执行相关mysql命令(我们执行的是,show procedure status)时提示 mysql.proc表crashed,无法修复(marked as crashed and last (automatic?) repair failed ) 报错信息:mysql table is marked as crashed and last (automatic?) repair failed 0x002  分析处理 mysql提供了检查和修复表的命令: my

Table is marked as crashed and should be repaired

错误如下: hibernate operation: could not execute query; uncategorized SQLException for SQL [select count(*) as y0_ from customer this_ where this_.customer_type=? order by this_.id desc]; SQL state [HY000]; error code [1194]; Table 'this_' is marked as c

【mysql】 is marked as crashed and should be repaired

-备份数据库时报错 [ERROR] /usr/sbin/mysqld: Table './daifans/wp_options' is marked as crashed and should be repaired - 在网上查了文档,说是表损坏,所以 WordPress 的文章都显示不出来,需要修复,修复前需要备份 我备份时也出错了,说是损坏的那个表备份不了的意思,我就用排除废表备份其他的 # mysqldump -uroot -p  dbname --ignore-table=dbname

导出Mysql数据库出错:Got error: 145: Table 'wp_options' is marked as crashed and should be repaired when using LOCK TABLES的解决方法

mysqldump: Got error: 145: Table 'wp_options' is marked as crashed and should be repaired when using LOCK TABLES 错误如上所示. 今天在给自己的wp网站搬家的时候,导出数据时发现导不出来,报了如上的错误,在网上找了一下资料,说是这张张被标记有问题,需要优化.参考: http://www.cnblogs.com/hakuci/archive/2012/03/20/2407723.html

[MySQL]快速解决"Table '.\sjzlf\zbp_post' is marked as crashed and should be repaired"故障

为了不冒失修复,故采取保守做法,我们知道 MySQL 一个高效的管理工具便是 PhpMyAdmin,而在该管理软件中就包含了对表的检查.分析.修复.优化功能,比起网上提供的含糊命令行来说更安全更简便. 通过实践,在使用检查表功能后确实发现了问题,之后使用修复功能进行了修复,反馈结果每个表都已经 ok,再执行一次优化,重新测试访问网站终于恢复了正常.一场灾难就此避免-- [MySQL]快速解决"Table '.\sjzlf\zbp_post' is marked as crashed and sh

[MySQL]快速解决"is marked as crashed and should be repaired"故障

具体报错如下: Table '.\Tablename\posts' is marked as crashed and should be repaired 提示说论坛的帖子表posts被标记有问题,需要修复.我记得以前也出现过类似的问题,但是只要点击Phpmyadmin上的repair按纽就自动修复了,但是这次很绝,什么都没有.于是赶快上网查找原因.最终将问题解决.解决方法如下: 找到mysql的安装目录的bin/myisamchk工具,在命令行中输入: myisamchk -c -r ../d