Home > Backend Development > PHP Tutorial > 自动修复crashed的数据表

自动修复crashed的数据表

WBOY
Release: 2016-06-23 14:23:22
Original
1074 people have browsed it

mysql crashed

function check_table($table){	require dirname(__FILE__) .'/connection.php';	mysql_select_db("news",$db);	$ret = mysql_query("SHOW TABLE STATUS WHERE `name` = '".$table."'");	while($row = mysql_fetch_array($ret)){		if($row['Engine']!='MyISAM'){			$wrong=1;			}	}	if($wrong){		mysql_query("REPAIR TABLE ".$table);	}	mysql_close($db);	$wrong=$ret=$row=NULL;}
Copy after login

上面的代码是不是可以检查数据表是否crashed?
crashed的数据表是不是 $row['Engine'] = null?
没找到相关的文章,求助各位前辈。


回复讨论(解决方案)

13.5.2.6. REPAIR TABLE语法
REPAIR [LOCAL | NO_WRITE_TO_BINLOG] TABLE
tbl_name [, tbl_name] ... [QUICK] [EXTENDED] [USE_FRM]
REPAIR TABLE用于修复被破坏的表。默认情况下,REPAIR TABLE与myisamchk --recover tbl_name具有相同的效果。REPAIR TABLE 对MyISAM和ARCHIVE表起作用。
而你却是在 !='MyISAM' 的条件下执行 REPAIR TABLE

13.5.2.6. REPAIR TABLE语法
REPAIR [LOCAL | NO_WRITE_TO_BINLOG] TABLE
tbl_name [, tbl_name] ... [QUICK] [EXTENDED] [USE_FRM]
REPAIR TABLE用于修复被破坏的表。默认情况下,REPAIR TABLE与myisamchk --recover tbl_name具有相同的效果。REPAIR TABLE 对MyISAM和ARCHIVE表起作用。
而你却是在 !='MyISAM' 的条件下执行 REPAIR TABLE


数据表格式为MyISAM,当数据表错误时,在phpmyadmin里显示表的状态为in use。
那么,怎么样的mysql语句,可以检查数据表错误,然后执行REPAIR TABLE语句?
谢谢。

好像应该是

if($row["Collation"]=='in use'){
Copy after login

对吗?
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template