MySQL 检查崩溃的表

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9111857/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 11:59:26  来源:igfitidea点击:

MySQL check for crashed table

mysql

提问by Adrien Hingert

I notice that when phpMyAdmin opens a DB it shows immediately if a table has crashed or not. It thus seems to me that phpMyAdmin is not running a CHECK TABLEor ANALYZE TABLE.

我注意到当 phpMyAdmin 打开一个数据库时,它会立即显示表是否崩溃。因此在我看来 phpMyAdmin 没有运行CHECK TABLEANALYZE TABLE.

Does anybody know what it does to obtain this informaiton so quickly and efficiently?

有人知道如何快速有效地获取这些信息吗?

回答by Martin.

I bet that

我敢打赌

SHOW TABLE STATUS FROM `db` 

is the thing you're looking for.

是你要找的东西。

Take a look at thisline. I think that if ENGINE is null (empty), it may be because table is crashed

看看条线。我认为如果ENGINE为null(空),可能是因为表崩溃了

回答by Soap Hope

show table status where comment like '%crash%';

回答by jeff-h

The most efficient way I have found is to use the commandline mysqlchecktool:

我发现的最有效的方法是使用命令行mysqlcheck工具:

mysqlcheck -u mydbuser -p mydbname

mysqlcheck -u mydbuser -p mydbname

This will access mydbnameusing user mydbuserand prompting for that user's password. It will then check each table in the specified database.

这将mydbname使用用户访问mydbuser并提示输入该用户的密码。然后它将检查指定数据库中的每个表。

See https://dev.mysql.com/doc/refman/5.7/en/mysqlcheck.html

https://dev.mysql.com/doc/refman/5.7/en/mysqlcheck.html

Note: this is not how phpMyAdmin does it, so this is not strictly an answer for the original question, but I'm putting this here because Google sends searches for mysql show crashed tableshere.

注意:这不是 phpMyAdmin 的做法,因此严格来说这不是原始问题的答案,但我将其放在这里是因为 Google 在这里发送搜索mysql show crashed tables

回答by Fedir RYKHTIK

If you have a shell access, the mysqlanalyzeutility could help.

如果您有 shell 访问权限,该mysqlanalyze实用程序可能会有所帮助。

mysqlanalyze dbname

Official Documentation

官方文档