MySQL表被标记为崩溃 [英] MySQL table is marked as crashed

查看:235
本文介绍了MySQL表被标记为崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是MySQL数据库的新手.我反复看到MySQL错误,说该表被标记为崩溃,应该修复.但是,我可以通过使用命令myisamchk来修复崩溃的表.顺便说一句,我在MySQL中使用MYISAM数据库引擎.

I fairly new to MySQL database. I am repeatedly seeing an error from MySQL saying the table is marked as crashed and should be repaired. However I am able to repair the crashed table by using the command myisamchk. By the way, I am using MYISAM database engine in MySQL.

我只是想知道在什么情况下数据库表会崩溃以及如何防止它再次发生?

I just wanted to know under what circumstances would a DB table crash and how I can prevent it from happening again?

我正在使用mysqltcl库(3.0)从Tcl(8.5)脚本连接到MySQL(5.0)数据库.

I am connecting to MySQL(5.0) database from Tcl (8.5) script using mysqltcl library (3.0).

推荐答案

MyISAM表很容易崩溃.每个表中都有标头信息,用于跟踪MyISAM表具有多少个打开文件句柄.

MyISAM tables are very easy to crash. There is header info in each table that keeps track of how many open file handles a MyISAM table has.

如果mysqld崩溃,则任何具有打开的文件句柄的MyISAM表都永远不会有机会在每次关闭文件句柄时减少文件句柄计数.因此,如果新文件句柄打开了MyISAM表(.MYD文件),并且mysqld发现MyISAM表认为已打开的文件句柄数与MyISAM表实际上已打开的文件句柄数之间不匹配,则该表为宣布坠毁.

If mysqld crashes, any MyISAM table that had open file handles to it never had the opportunity to decrement the file handle count upon each file handle closing. Thus, if a new file handle opens a MyISAM table (.MYD file) and mysqld discovers a mismatch between the number of file handles a MyISAM table believes is open and the the number of file handles the MyISAM table actually has open, the table is declared crashed.

有四(4)种方法可以处理此问题:

There are four(4) methods for handling this:

有关如何操作,请参见我的帖子 https://dba.stackexchange.com/a/15079/877 在MySQL重新启动时进行设置(2012年3月15日)

See my post https://dba.stackexchange.com/a/15079/877 on how to set this up upon a MySQL restart (Mar 15, 2012)

InnoDB在存储引擎的初始化中内置了崩溃恢复功能. MyISAM没有

InnoDB has crash recovery built into the Storage Engine's initialization. MyISAM does not

Aria是MariaDB的MyISAM的替代产品.它具有针对单个表的崩溃恢复机制.

Aria is MariaDB's drop-in replacement for MyISAM. It features crash recovery mechanisms for individual tables.

如果mysqld有意或无意地崩溃,所有打开的MyISAM表的标头信息将使它们进入崩溃状态.避免必须手动杀死mysqld.

If mysqld crashes, deliberately or involuntarily, header info for all open MyISAM tables will get them into a crashed state. Avoid having to manually kill mysqld.

这篇关于MySQL表被标记为崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆