1个数据库的MySQL超时,其他都正常 – MySQL和InnoDB数据字典不同步

我无法连接到MySQL的特定数据库,即使从phpMyAdmin,我得到以下错误:

#2002 - Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111) The server is not responding (or the local server's socket is not correctly configured).

在MySQL日志中我看到:

130404 1:18:09 InnoDB: MySQL and InnoDB data dictionaries are out of sync. InnoDB: Unable to find the AUTOINC column id in the InnoDB table strangedb/table. InnoDB: We set the next AUTOINC column value to 0, InnoDB: in effect disabling the AUTOINC next value generation. InnoDB: You can either set the next AUTOINC value explicitly using ALTER TABLE InnoDB: or fix the data dictionary by recreating the table. 130404 1:25:13 InnoDB: MySQL and InnoDB data dictionaries are out of sync. InnoDB: Unable to find the AUTOINC column id in the InnoDB table strangedb/table. InnoDB: We set the next AUTOINC column value to 0, InnoDB: in effect disabling the AUTOINC next value generation. InnoDB: You can either set the next AUTOINC value explicitly using ALTER TABLE InnoDB: or fix the data dictionary by recreating the table. 130404 1:25:13 InnoDB: Assertion failure in thread 139934538761984 in file handler/ha_innodb.cc line 8290 InnoDB: Failing assertion: auto_inc > 0 InnoDB: We intentionally generate a memory trap. InnoDB: Submit a detailed bug report to http://bugs.mysql.com. InnoDB: If you get repeated assertion failures or crashes, even InnoDB: immediately after the mysqld startup, there may be InnoDB: corruption in the InnoDB tablespace. Please refer to InnoDB: http://dev.mysql.com/doc/refman/5.1/en/forcing-innodb-recovery.html InnoDB: about forcing recovery.

我可以确认MySQL正在为所有其他表正常工作。

我已经通过强制恢复的链接,但我不是一个MySQL的忍者,我可以select * from strangedb.table; 好,列出内容,下一步转储数据并重新导入到一个新表中将是什么?

这原来是像提到的错误一样的腐败。 我能够通过MySQL实用程序查看表格的内容,并执行以下操作:

  1. 从损坏的表的现有架构中创build一个新表
  2. 将数据从旧数据复制到新数据

下面的命令:

 USE strangedb; CREATE TABLE table_new LIKE table; INSERT table_new SELECT * FROM table; 

一旦安全复制,我可以删除旧表DROP TABLE table; 并重命名救生艇表RENAME TABLE table_new TO table;

在我的情况下,这是确定的,因为我没有任何关联约束,我会想象更复杂的情况下,将需要重新创build。