2022-10-27 348
修复mysql表是我们经常需要用到的,下面就教您两种修复mysql表的的方法,如果您之前遇到过此方面的问题,不妨一看。
修复mysql表第一种方法:
shell>mysqlcheck-r-c-o-uuser-ppasswddb_name
修复mysql表第二种方法,用以下这个脚本,从网上下的,似很管用.将这个脚本放在你的web根目录下,然后从web页面运行这个脚本.
catrepair.php 需要修改 $dbuser="root";--->需要修改 $dbpw="";--->需要修改 $dbname="db_name";-->需要修改 #$table="search_profile"; mysql_connect($dbhost,$dbuser,$dbpw); mysql_select_db($dbname); if(!get_cfg_var("register_globals")){ foreach($HTTP_GET_VARSas$key=>$val){ $$key=$val; } } functionchecktable($table,$loops=0){ global$db,$nohtml; $result=mysql_query("CHECKTABLE$table"); if(!$nohtml){ echo"Checkingtable$table"; echo"TableOperationTypeText"; }else{ echo"\n>>>>>>>>>>>>>CheckingTable$table\n"; echo"--------------------------------- \n"; } $error=0; while($r=mysql_fetch_row($result)){ if($r[2]=='error'){ if($r[3]=="Thehandlerforthetabledoesn'tsupportcheck/repair"){ $r[2]='status'; $r[3]='Thistabledoesnotsupportcheck/repair/optimize'; unset($bgcolor); $nooptimize=1; }else{ $error=1; $bgcolor='red'; unset($nooptimize); } }else{ unset($bgcolor); unset($nooptimize); } if(!$nohtml){ echo"$r[0]$r[1]$r[2]$r[3]"; }else{ echo"$r[0]|$r[1]|$r[2]|$r[3] \n"; } } if($error){ if(!$nohtml){ echo"Repairingtable$table"; }else{ echo">>>>>>>>>>>>>RepairingTable$table \n"; } $result2=mysql_query("REPAIRTABLE$table"); if($result2[3]!='OK') $bgcolor='red'; else unset($bgcolor); if(!$nohtml){ echo"$result2[0]$result2[1]$result2[2]$result2[3]"; }else{ echo"$result2[0]|$result[1]|$result2[2]|$result2[3] \n"; } } if(($result2[3]=='OK'||!$error)&&!$nooptimize){ if(!$nohtml){ echo"Optimizingtable$table"; }else{ echo">>>>>>>>>>>>>OptimizingTable$table \n"; } $result3=mysql_query("OPTIMIZETABLE$table"); $error=0; while($r3=mysql_fetch_row($result3)){ if($r3[2]=='error'){ $error=1; $bgcolor='red'; }else{ unset($bgcolor); } if(!$nohtml){ echo"$r3[0]$r3[1]$r3[2]$r3[3]"; }else{ echo"$r3[0]|$r3[1]|$r3[2]|$r3[3] \n"; } } } if($error&&$loops){ checktable($table,($loops-1)); } } if($check){ $tables=mysql_query("SHOWTABLES"); if(!$nohtml){ echo""; } if($iterations){ $iterations--; } while($table=mysql_fetch_row($tables)){ if(substr($table[0],-8)!='sessions'){ $answer=checktable($table[0],$iterations); if(!$nohtml){ echo" "; } flush(); } } if(!$nohtml){ echo""; } }else{ echo"DatabaseTableRepairUtilityforDiscuz!(RequireMySQL3.23) ". "Thisscriptwillattempttorepaircorrupteddatabases.Whileitcanrepairmostcommonerrors, ". "itcannotrepaireverything.Asasidebenefititwillalsooptimizeyourtables. ". "ThisscriptwascopyrightedbyJelsoftandmodifiedbyCrossdayStudiotomakeitapplyforDiscuz!. ". "Usage: ". "iterations=x(xisthenumberoftimesyouwishforthescripttoattempttorepairabrokentable) ". "nohtml=1(Outputtextonlynohtml.Usefulforcronjobsandyouwishtoreceivetextonly) ". "check=1(withoutthisyouwillgetthisscreenandnochecking) ". "ExampleUsage: ". "repair.php?html=1&check=1(mostcommonusage,willcheckaforumandreturnhtmlresults) "."repair.php?check=1&iterations=5(trytorepairdamagedtables5times)". ""; } ?>
原文链接:https://77isp.com/post/4388.html
=========================================
https://77isp.com/ 为 “云服务器技术网” 唯一官方服务平台,请勿相信其他任何渠道。
数据库技术 2022-03-28
网站技术 2022-11-26
网站技术 2023-01-07
网站技术 2022-11-17
Windows相关 2022-02-23
网站技术 2023-01-14
Windows相关 2022-02-16
Windows相关 2022-02-16
Linux相关 2022-02-27
数据库技术 2022-02-20
抠敌 2023年10月23日
嚼餐 2023年10月23日
男忌 2023年10月22日
瓮仆 2023年10月22日
簿偌 2023年10月22日
扫码二维码
获取最新动态