早上不知道怎么一下误操作,导致MYSQL数据库出错。情况大致如此: 
我的数据库里本有四个库:A:[a,我的数据库]
B: [information_schema,MYSQL数据库自带的]
C: [mysql, MYSQL自带的]
D: [test, 测试表,无数据]我在修改了ROOT密码以后,然后删除了一些东西,是C库里面的user表里的几条记录,本来一共有四条,我看后面两条无用就给删除了。然后MYSQL开始出错:
1,A库消失。
2,我用phpmyadmin查看数据库,提示我无权限创建数据库,我是用root帐号的。
3,C库消失。
4,在系统内可以进入MYSQL,就是MYSQL >这样,也无法创建数据库。不知道怎么回事。
我查看了A库和C库内的所有文件是存在的,但是就是用PHPMYADMIN无法看到,用SHOW DATABASES 也无法看到。
我拷贝了A库内的东西,到别的机器上,发现A库的MyISAM类型的表数据是存在的,但是InnoDB类型的数据就没有了。大家帮帮忙。

解决方案 »

  1.   

    大概数据库表损坏了
    修复一下吧
    运行文件
    <?phperror_reporting(7);
     
    $dbhost="localhost";
    $dbuser="root";
    $dbpw="";
    $dbname="otrs";
    #$table="search_profile";mysql_connect($dbhost, $dbuser, $dbpw);
    mysql_select_db($dbname);if(!get_cfg_var("register_globals")) {
    foreach($HTTP_GET_VARS as $key => $val) {
    $$key = $val;
    }
    }function checktable($table, $loops = 0) {
      global $db, $nohtml;   $result = mysql_query("CHECK TABLE $table");
       if(!$nohtml) {
         echo "<tr bgcolor='#CCCCCC'><td colspan=4 align='center'>Checking table $table</td></tr>";
         echo "<tr><td>Table</td><td>Operation</td><td>Type</td><td>Text</td></tr>";
       } else {
         echo "\n>>>>>>>>>>>>>Checking Table $table\n";
         echo "---------------------------------<br>\n";
       }
       $error = 0;
       while($r = mysql_fetch_row($result)) {
         if($r[2] == 'error') {
           if($r[3] == "The handler for the table doesn't support check/repair") {
             $r[2] = 'status';
             $r[3] = 'This table does not support check/repair/optimize';
             unset($bgcolor);
             $nooptimize = 1;
           } else {
             $error = 1;
             $bgcolor = 'red';
             unset($nooptimize);
           }
         } else {
           unset($bgcolor);
           unset($nooptimize);
         }
         if(!$nohtml) {
           echo "<tr><td>$r[0]</td><td>$r[1]</td><td bgcolor='$bgcolor'>$r[2]</td><td>$r[3]</td></tr>";
         } else {
           echo "$r[0] | $r[1] | $r[2] | $r[3]<br>\n";
         }
       }
       if($error) {
         if(!$nohtml) {
           echo "<tr><td colspan=4 align='center'>Repairing table $table</td></tr>";
         } else {
           echo ">>>>>>>>>>>>>Repairing Table $table<br>\n";
         }
         $result2=mysql_query("REPAIR TABLE $table");
         if($result2[3]!='OK')
           $bgcolor='red';
         else
           unset($bgcolor);
         if(!$nohtml) {
           echo "<tr><td>$result2[0]</td><td>$result2[1]</td><td>$result2[2]</td><td bgcolor='$bgcolor'>$result2[3]</td></tr>";
         } else {
           echo "$result2[0] | $result[1] | $result2[2] | $result2[3]<br>\n";
         }
       }
       if(($result2[3]=='OK'||!$error)&&!$nooptimize) {
         if(!$nohtml) {
           echo "<tr><td colspan=4 align='center'>Optimizing table $table</td></tr>";
         } else {
           echo ">>>>>>>>>>>>>Optimizing Table $table<br>\n";
         }
         $result3=mysql_query("OPTIMIZE TABLE $table");
         $error=0;
         while($r3=mysql_fetch_row($result3)) {
           if($r3[2]=='error') {
             $error=1;
             $bgcolor='red';
           } else {
             unset($bgcolor);
           }
           if(!$nohtml) {
             echo "<tr><td>$r3[0]</td><td>$r3[1]</td><td bgcolor='$bgcolor'>$r3[2]</td><td>$r3[3]</td></tr>";
           } else {
             echo "$r3[0] | $r3[1] | $r3[2] | $r3[3]<br><br>\n";
           }
         }
       }
       if($error&&$loops) {
         checktable($table,($loops-1));
       }
    }if($check) {  $tables=mysql_query("SHOW TABLES");  if(!$nohtml) {
        echo "<HTML><HEAD></HEAD><BODY><table border=1 cellspacing=0 cellpadding=4 STYLE=\"font-family: Tahoma, Verdana; font-size: 11px\">";
      }  if($iterations) {
        $iterations--;
      }
      while($table=mysql_fetch_row($tables)) {     if(substr($table[0], -8) != 'sessions') {
           $answer=checktable($table[0],$iterations);
           if(!$nohtml) {
             echo "<tr><td colspan=4>&nbsp;</td></tr>";
           }
           flush();
         }
      }  if(!$nohtml) {
        echo "</table></BODY></HTML>";
      }
    } else {
      echo "<HTML><HEAD></HEAD><BODY STYLE=\"font-family: Tahoma, Verdana; font-size: 11px\"><b>Database Table Repair Utility for Discuz! (Require MySQL 3.23+)</b><br><br>".
           "This script will attempt to repair corrupted databases. While it can repair most common errors,<br>".
           "it can not repair everything. As a side benefit it will also optimize your tables.<br>".
           "This script was copyrighted by Jelsoft and modified by Crossday Studio to make it apply for Discuz!.<br><br>".
           "Usage:<br><br>".
           "<b>iterations=x</b> (x is the number of times you wish for the script to attempt to repair a broken table)<br>".
           "<b>nohtml=1</b> (Output text only no html. Useful for cronjobs and you wish to receive text only)<br>".
           "<b>check=1</b> (without this you will get this screen and no checking)<br><br>".
           "Example Usage:<br><br>".
           "<b><a href=\"repair.php?check=1&iterations=5\">repair.php?html=1&check=1</a></b> (most common usage, will check a forum and return html results)<br>".
           "<b><a href=\"repair.php?check=1&iterations=5\">repair.php?check=1&iterations=5</a></b> (try to repair damaged tables 5 times)".
           "</BODY></HTML>";
    }
    ?>