删除崩溃的 Innodb 表

发布于 2024-09-08 18:22:44 字数 225 浏览 11 评论 0原文

我无法删除/删除崩溃的 Innodb 表。我收到以下错误:

ERROR 1051 (42S02): Unknown table 'accounts'

如果我想创建它,我收到以下错误:

ERROR 1005 (HY000): Can't create table 'accounts' (errno: -1)

我的服务器在意外断电后会发生这种情况。

问候

I cannot delete/drop a crashed Innodb table. I get the following error:

ERROR 1051 (42S02): Unknown table ‘accounts’

And if I want to create it I get the following error:

ERROR 1005 (HY000): Can’t create table ‘accounts’ (errno: -1)

This happens on my server after an accidental power failure.

Regards

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

惜醉颜 2024-09-15 18:22:44

我在这里也发现了这个问题 http://www.randombugs.com/linux/crash -innodb-table.html 似乎只需删除 ibdata 文件并重新启动 mysql 就可以解决这个问题。无论如何,如果您没有任何备份,这并不是真正的解决方案。

I also found this problem here http://www.randombugs.com/linux/crash-innodb-table.html and it seems just deleting ibdata file and restarting mysql can solve this. Anyway this is not truly a solution if you don't have any backup.

蓝海 2024-09-15 18:22:44

在删除表之前关闭外键约束有帮助吗?

set foreign_key_checks=0;
drop table <table>;
set foreign_key_checks=1;

有一个错误报告详细介绍了类似的内容,但我不清楚是否是同一问题:

http://bugs.mysql.com/bug.php?id=5784

如果没有,你可以尝试 mysqlcheck

mysqlcheck -u root -p <dbname> --auto-repair --check --optimize --databases

您必须检查文档以找到最适合您的数据库的选项。请务必注意文档第一段中有关此命令运行时放置在表上的锁的注释。

Does turning off foreign key constraints prior to dropping the table help?

set foreign_key_checks=0;
drop table <table>;
set foreign_key_checks=1;

There is a bug report which details something similar, but I'm not clear if it is the same issue:

http://bugs.mysql.com/bug.php?id=5784

If not, you could try mysqlcheck:

mysqlcheck -u root -p <dbname> --auto-repair --check --optimize --databases

You'll have to check the docs for the most appropriate options for your database. Be sure to note the comments in the first paragraph of the docs about the locks that are placed on tables while this command is running.

旧情别恋 2024-09-15 18:22:44

我的猜测是 InnoDB 甚至没有加载(检查 SHOW ENGINES),因此在您首先解决该问题之前您将无法删除它。

通常你可以在恢复模式3下启动InnoDB,删除你需要的任何内容,然后关闭并删除恢复模式设置:

http://dev.mysql.com/doc/refman/5.0/en/forcing-recovery.html

My guess is that InnoDB isn't even loaded (check SHOW ENGINES), so you're not going to be able to DROP it until you fix that problem first.

Usually you can start InnoDB up in recovery mode 3, drop whatever you need, and then shutdown and remove the recovery mode setting:

http://dev.mysql.com/doc/refman/5.0/en/forcing-recovery.html

゛清羽墨安 2024-09-15 18:22:44

对我有用的简单解决方案。

  1. 尝试删除该表。

    删除表tableOne;

您将看到错误:

ERROR 1051 (42S02): Unknown table 'tableOne'
  1. 从另一个数据库复制该表的创建语句或写入它。

    创建表tableOne (ID int(11) NOT NULL, LOCKED tinyint(1) NOT NULL) ENGINE=InnoDB;

成功

Query OK, 0 rows affected (0.03 sec)
  1. 删除表格

    删除表tableOne;  
    

成功

    Query OK, 0 rows affected (0.01 sec) 

Simple solution that worked for me.

  1. Try to delete the table.

    drop table tableOne;

You will see error:

ERROR 1051 (42S02): Unknown table 'tableOne'
  1. Copy the create statement of that table from another Database or write it.

    CREATE TABLE tableOne ( ID int(11) NOT NULL, LOCKED tinyint(1) NOT NULL) ENGINE=InnoDB;

Successful

Query OK, 0 rows affected (0.03 sec)
  1. Drop the table

    drop table tableOne;  
    

Successful

    Query OK, 0 rows affected (0.01 sec) 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文