成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

修復mysql表的兩種方法

數據庫 MySQL
如果mysql表損壞了,我們就需要進行修復,下文就為您介紹兩種最常用的兩種修復損壞表的方法,希望對您能夠有所幫助。

修復mysql表是我們經常需要用到的,下面就教您兩種修復mysql表的的方法,如果您之前遇到過此方面的問題,不妨一看。

修復mysql表第一種方法:

  1. shell> mysqlcheck -r -c -o -uuser -ppasswd db_name  

修復mysql表第二種方法,用以下這個腳本,從網上下的,似很管用.將這個腳本放在你的web根目錄下,然后從web頁面運行這個腳本.

  1. cat repair.php  
  2. 需要修改  
  3. $dbuser="root"; --->需要修改  
  4. $dbpw=""; --->需要修改  
  5. $dbname="db_name"; -->需要修改  
  6. #$table="search_profile";  
  7. mysql_connect($dbhost, $dbuser, $dbpw);  
  8. mysql_select_db($dbname);  
  9. if(!get_cfg_var("register_globals")) {  
  10. foreach($HTTP_GET_VARS as $key => $val) {  
  11. $$key = $val;  
  12. }  
  13. }  
  14. function checktable($table, $loops = 0) {  
  15. global $db, $nohtml;  
  16. $result = mysql_query("CHECK TABLE $table");  
  17. if(!$nohtml) {  
  18. echo "Checking table $table";  
  19. echo "TableOperationTypeText";  
  20. } else {  
  21. echo "\n>>>>>>>>>>>>>Checking Table $table\n";  
  22. echo "---------------------------------  
  23. \n";  
  24. }  
  25. $error = 0;  
  26. while($r = mysql_fetch_row($result)) {  
  27. if($r[2] == 'error') {  
  28. if($r[3] == "The handler for the table doesn't support check/repair") {  
  29. $r[2] = 'status';  
  30. $r[3] = 'This table does not support check/repair/optimize';  
  31. unset($bgcolor);  
  32. $nooptimize = 1;  
  33. } else {  
  34. $error = 1;  
  35. $bgcolor = 'red';  
  36. unset($nooptimize);  
  37. }  
  38. } else {  
  39. unset($bgcolor);  
  40. unset($nooptimize);  
  41. }  
  42. if(!$nohtml) {  
  43. echo "$r[0]$r[1]$r[2]$r[3]";  
  44. } else {  
  45. echo "$r[0] | $r[1] | $r[2] | $r[3]  
  46. \n";  
  47. }  
  48. }  
  49. if($error) {  
  50. if(!$nohtml) {  
  51. echo "Repairing table $table";  
  52. } else {  
  53. echo ">>>>>>>>>>>>>Repairing Table $table  
  54. \n";  
  55. }  
  56. $result2=mysql_query("REPAIR TABLE $table");  
  57. if($result2[3]!='OK')  
  58. $bgcolor='red';  
  59. else  
  60. unset($bgcolor);  
  61. if(!$nohtml) {  
  62. echo "$result2[0]$result2[1]$result2[2]$result2[3]";  
  63. } else {  
  64. echo "$result2[0] | $result[1] | $result2[2] | $result2[3]  
  65. \n";  
  66. }  
  67. }  
  68. if(($result2[3]=='OK'||!$error)&&!$nooptimize) {  
  69. if(!$nohtml) {  
  70. echo "Optimizing table $table";  
  71. } else {  
  72. echo ">>>>>>>>>>>>>Optimizing Table $table  
  73. \n";  
  74. }  
  75. $result3=mysql_query("OPTIMIZE TABLE $table");  
  76. $error=0;  
  77. while($r3=mysql_fetch_row($result3)) {  
  78. if($r3[2]=='error') {  
  79. $error=1;  
  80. $bgcolor='red';  
  81. } else {  
  82. unset($bgcolor);  
  83. }  
  84. if(!$nohtml) {  
  85. echo "$r3[0]$r3[1]$r3[2]$r3[3]";  
  86. } else {  
  87. echo "$r3[0] | $r3[1] | $r3[2] | $r3[3]  
  88. \n";  
  89. }  
  90. }  
  91. }  
  92. if($error&&$loops) {  
  93. checktable($table,($loops-1));  
  94. }  
  95. }  
  96. if($check) {  
  97. $tables=mysql_query("SHOW TABLES");  
  98. if(!$nohtml) {  
  99. echo "";  
  100. }  
  101. if($iterations) {  
  102. $iterations--;  
  103. }  
  104. while($table=mysql_fetch_row($tables)) {  
  105. if(substr($table[0], -8) != 'sessions') {  
  106. $answer=checktable($table[0],$iterations);  
  107. if(!$nohtml) {  
  108. echo " ";  
  109. }  
  110. flush();  
  111. }  
  112. }  
  113. if(!$nohtml) {  
  114. echo "";  
  115. }  
  116. } else {  
  117. echo "Database Table Repair Utility for Discuz! (Require MySQL 3.23 )  
  118. ".  
  119. "This script will attempt to repair corrupted databases. While it can repair most common errors,  
  120. ".  
  121. "it can not repair everything. As a side benefit it will also optimize your tables.  
  122. ".  
  123. "This script was copyrighted by Jelsoft and modified by Crossday Studio to make it apply for Discuz!.  
  124. ".  
  125. "Usage:  
  126. ".  
  127. "iterations=x (x is the number of times you wish for the script to attempt to repair a broken table)  
  128. ".  
  129. "nohtml=1 (Output text only no html. Useful for cronjobs and you wish to receive text only)  
  130. ".  
  131. "check=1 (without this you will get this screen and no checking)  
  132. ".  
  133. "Example Usage:  
  134. ".  
  135. "repair.php?html=1&check=1 (most common usage, will check a forum and return html results)  
  136. ". "repair.php?check=1&iterations=5 (try to repair damaged tables 5 times)".  
  137. "";  
  138. }  
  139. ?> 

 

 

 

【編輯推薦】

MySQL表管理命令介紹

php mysql創建臨時表

mysql快速建表的方法

mysql表索引的相關信息

深入研究MySQL刪除多表數據

責任編輯:段燃 來源: 互聯網
相關推薦

2010-06-17 12:48:05

livecd 修復Gr

2011-03-30 17:04:24

MySQL添加用戶

2010-08-04 17:41:52

掛載NFS

2011-07-14 17:50:50

domino數據庫

2010-05-24 15:08:46

MySQL訪問權限

2010-11-23 11:53:37

MySQL查詢表字段

2009-09-25 14:04:09

Hibernate eHibernate h

2010-04-13 09:50:44

Oracle跟蹤

2010-09-02 10:36:51

SQL刪除

2010-08-26 16:49:09

DB2導入導出

2011-08-30 15:28:33

Oracle 10g表

2010-02-06 14:35:36

ibmdwRUP迭代

2010-09-09 19:53:50

2009-08-05 13:34:18

C#日期相減

2009-06-18 11:09:42

2020-09-16 18:27:36

Linux方法IP地址

2019-09-15 17:35:28

Wireshark解密HTTPS

2010-11-12 11:44:37

SQL Server刪

2010-09-07 11:18:10

2011-05-24 09:18:59

C++連接mysql數據庫
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 欧美专区在线 | 国产精品国产精品国产专区不卡 | 久久亚洲一区二区 | 日本一区二区三区免费观看 | 一区在线观看 | 九九99靖品 | 超碰成人在线观看 | 超碰日本 | 尤物视频在线免费观看 | 欧美精品一区二区三区在线 | 中文字幕一区二区三区日韩精品 | 成人免费一区二区三区视频网站 | 欧美一级欧美一级在线播放 | 中文字幕一区二区三区四区 | 成人av电影在线 | 午夜小视频在线播放 | 精品视频亚洲 | 国产视频一二三区 | 欧美日韩国产在线观看 | 91精品国产99 | 久久久久中文字幕 | 日韩欧美国产一区二区 | 狠狠亚洲 | 亚洲乱码国产乱码精品精98午夜 | 日韩三级一区 | 久久成人国产精品 | 久久久久亚洲精品国产 | 视频一区二区中文字幕 | 久久99久久99精品免视看婷婷 | 欧美jizzhd精品欧美巨大免费 | 国产精品一区在线观看 | 久久69精品久久久久久久电影好 | 色综合久久天天综合网 | 久久久久久久久久久爱 | 成人免费视频网站在线看 | 国产97色 | 自拍偷拍第一页 | 国产伦精品一区二区三区在线 | 久草电影网 | 欧产日产国产精品视频 | 日韩精品999|