【问题标题】:Can't create a table in MySQL because "it already exists"无法在 MySQL 中创建表,因为“它已经存在”
【发布时间】:2014-04-08 10:16:37
【问题描述】:

我遇到了与我的previous question 相关的 MySQL 问题。

我最近需要从 MySQL 中删除一个表,现在需要创建一个新表来代替它。我很难做到这一点,因为正如 MySQL Workbench 所说,“该表已经存在。”由于来自 MySQL Workbench 的错误并不是特别有用,因此这里是我从错误日志中提取的一些内容。有什么问题?

我在 Windows 8.1 Pro x64 上运行 MySQL 5.7。

2014-03-06T01:38:55.459658Z 0 [ERROR] InnoDB: Table thepwf_prgminteractions/p2p_messagedata in the InnoDB data dictionary has tablespace id 25, but tablespace with that id or name does not exist. Have you deleted or moved .ibd files? This may also be a table created with CREATE TEMPORARY TABLE whose .ibd and .frm files MySQL automatically removed, but the table still exists in the InnoDB internal data dictionary.
InnoDB: Please refer to
InnoDB: http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting-datadict.html
InnoDB: for how to resolve the issue.
2014-03-06T01:38:55.464671Z 0 [ERROR] InnoDB: Table thepwf_prgminteractions/p2p_onlineusers in the InnoDB data dictionary has tablespace id 26, but tablespace with that id or name does not exist. Have you deleted or moved .ibd files? This may also be a table created with CREATE TEMPORARY TABLE whose .ibd and .frm files MySQL automatically removed, but the table still exists in the InnoDB internal data dictionary.
InnoDB: Please refer to
InnoDB: http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting-datadict.html
InnoDB: for how to resolve the issue.
2014-03-06T01:38:55.468672Z 0 [ERROR] InnoDB: Table thepwf_prgminteractions/p2pchat_betaaccesskeys in the InnoDB data dictionary has tablespace id 24, but tablespace with that id or name does not exist. Have you deleted or moved .ibd files? This may also be a table created with CREATE TEMPORARY TABLE whose .ibd and .frm files MySQL automatically removed, but the table still exists in the InnoDB internal data dictionary.

【问题讨论】:

    标签: mysql windows-8.1


    【解决方案1】:

    转到安装 mysql 文件夹的位置: C:\Apps\mysql-5.6.25-win64\data\databasename

    在 databasename 下,您将找到您的表名。手动删除此表,然后使用 SQL Create Table 命令重新创建。

    【讨论】:

      【解决方案2】:

      看起来您的 innodb 表空间已损坏。

      从 percona 查看这篇文章

      http://www.mysqlperformanceblog.com/2008/07/04/recovering-innodb-table-corruption/

      还有这些工具

      http://www.percona.com/software/percona-toolkit

      他们会救你的!

      好吧,我不知道它们在 Windows 上的运行情况如何,但工具的作用应该差不多。

      【讨论】:

      • 我不知道如何使用这些工具来解决问题,即使在阅读了两个页面之后。我注意到,当我将lower_case_table_names 设置为2 时,只有名称中带有下划线的表才会出现此问题。
      【解决方案3】:

      由于表存在,所以只需使用 drop table (http://dev.mysql.com/doc/refman/5.6/en/drop-table.html) 将其删除

      drop table <table name>
      

      你肯定做错了什么,因为表仍然存在。

      可以通过select查看这个

      select * from <table name>
      

      【讨论】:

      • drop table thepwf_prgminteractions 返回“未知表”错误。
      • @davidB - 您是否使用了正确的数据库,即事先使用 use &lt;database&gt;
      • 是的。另外,我在评论中提出的查询是错误的。我的意思是说p2pChat_betaAccessKeys
      猜你喜欢
      • 2019-05-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-03
      • 1970-01-01
      • 2013-06-29
      • 2011-11-30
      • 2023-03-22
      相关资源
      最近更新 更多