MySQL 漏洞?#1146 - 表 'xxx.xxxxx' 不存在
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6342201/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Bug? #1146 - Table 'xxx.xxxxx' doesn't exist
提问by Shaheer
I am using windows XP. I am creating a table in phpMyAdmin using its built-in create table feature,
my database name is ddd
.
我正在使用 Windows XP。我正在使用其内置的创建表功能在 phpMyAdmin 中创建一个表,我的数据库名称是ddd
.
It generates the following code:
它生成以下代码:
CREATE TABLE `ddd`.`mwrevision` (
`asd` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`sddd` INT NOT NULL
) ENGINE = INNODB;
and the following error shows up:
并出现以下错误:
MySQL said:
#1146 - Table 'ddd.mwrevision' doesn't exist
What might be the problem?
可能是什么问题?
采纳答案by sempasha
I also had same problem in past. All had happend after moving database files to new location and after updating mysql server. All tables with InnoDB engine disappeared from my database. I was trying to recreate them, but mysql told me 1146: Table 'xxx' doesn't exist
all the time until I had recreated my database and restarted mysql service.
我过去也遇到过同样的问题。所有这些都是在将数据库文件移动到新位置并更新 mysql 服务器之后发生的。所有带有 InnoDB 引擎的表都从我的数据库中消失了。我试图重新创建它们,但 mysql 一直告诉我1146: Table 'xxx' doesn't exist
,直到我重新创建了我的数据库并重新启动了 mysql 服务。
I think there's a need to read about InnoDB table binaries.
我认为有必要阅读 InnoDB 表二进制文件。
回答by carlos
I had the same problem and can't get a good tip for this over the web, so I shared this for you and for all who needs.
我遇到了同样的问题,无法通过网络获得有关此问题的好的提示,因此我将其分享给您和所有需要的人。
In my situation I copy a database (all files: frm, myd) to the data folder in MySQL data folder (using Wamp at home). All thing was OK until I want to create a table and have the error #1146 Table '...' doesn't exist!
.
在我的情况下,我将数据库(所有文件:frm、myd)复制到 MySQL 数据文件夹中的数据文件夹(在家使用 Wamp)。一切正常,直到我想创建一个表并出现错误#1146 Table '...' doesn't exist!
。
I use Wamp 2.1 with MySQL version 5.5.16.
我将 Wamp 2.1 与 MySQL 5.5.16 版一起使用。
My solution:
我的解决方案:
Export the database to file;
verify if exported file is really OK!!;
drop the database where I have issues;
create a new database with the same name that the last;
import the file to the database.
将数据库导出到文件;
验证导出的文件是否真的没问题!!;
删除我有问题的数据库;
创建一个与上一个同名的新数据库;
将文件导入数据库。
FOR ME IS PROBLEM SOLVED. Now I can create tables again without errors.
对我来说问题解决了。现在我可以再次创建表而不会出错。
回答by Muhammad Usman
Restarting MySQL works fine for me.
重新启动 MySQL 对我来说很好。
回答by Jim 007
In my case I ran this command even if the table wasn't visible in PhpMyAdmin :
就我而言,即使该表在 PhpMyAdmin 中不可见,我也运行了此命令:
DROP TABLE mytable
DROP TABLE mytable
then
然后
CREATE TABLE....
CREATE TABLE....
Worked for me !
为我工作!
回答by blarg
Check filenames.
You might need to create a new databasein phpmyadmin that matches the database you're trying to import.
检查文件名。
您可能需要在 phpmyadmin 中创建一个与您尝试导入的数据库相匹配的新数据库。
回答by thekosmix
I had the same problem. I tried to create a table in mysql and got the same error. I restarted mysql server and ran the command and was able to create/migrate table after restating.
我有同样的问题。我试图在 mysql 中创建一个表并得到同样的错误。我重新启动了 mysql 服务器并运行了命令,并且能够在重新启动后创建/迁移表。
回答by Vipin Gurjar
Today i was facing same problem. I was in very difficult situation but what id did i create a table with diffrent name e.g (modulemaster was not creating then i create modulemaster1) and after creating table i just do the rename table.
今天我面临同样的问题。我处于非常困难的情况,但是我创建了一个具有不同名称的表,例如(modulemaster 没有创建,然后我创建了 modulemaster1),并且在创建表后我只是重命名表。
回答by SteveCinq
As pprakashmentions above, copying the table.frm filesAND the ibdata1file was what worked for me.
正如pprakash上面提到的,复制table.frm 文件和ibdata1文件对我有用。
In short:
简而言之:
- Shut your DB explorer client (e.g. Workbench).
- Stop the MySQL service (Windows host).
- Make a safe copy of virtually everything!
- Save a copy of the table file(s) (eg mytable.frm) to the schema data folder (e.g. MySQL Server/data/{yourschema}).
- Save a copy of the ibdata1file to the data folder (i.e., MySQL Server/data).
- Restart the MySQL service.
- Check that the tables are now accessible, queryable, etc. in your DB explorer client.
- 关闭您的数据库浏览器客户端(例如 Workbench)。
- 停止 MySQL 服务(Windows 主机)。
- 制作几乎所有内容的安全副本!
- 将表文件(例如mytable.frm)的副本保存到架构数据文件夹(例如 MySQL Server/data/{yourschema})。
- 将ibdata1文件的副本保存到数据文件夹(即 MySQL Server/data)。
- 重启 MySQL 服务。
- 检查您的数据库浏览器客户端中的表现在是否可访问、可查询等。
After that, all was well. (Don't forget to backup if you have success!)
在那之后,一切都很好。(成功了别忘了备份!)
回答by Xin
I encountered the same problem today. I was trying to create a table users
, and was prompted that ERROR 1146 (42S02): Table users doesn't exist
, which did not make any sense, because I was just trying to create the table!!
我今天遇到了同样的问题。我正在尝试创建一个表users
,并被提示ERROR 1146 (42S02): Table users doesn't exist
,这没有任何意义,因为我只是在尝试创建表!!
I then tried to drop the table by typing DROP TABLE users
, knowing it would fail because it did not exist, and I got an error, saying Unknown table users
. After getting this error, I tried to create the table again, and magically, it successfully created the table!
然后我尝试通过键入删除表DROP TABLE users
,知道它会失败,因为它不存在,我收到一个错误,说Unknown table users
. 得到这个错误后,我再次尝试创建表,神奇的是,它成功创建了表!
My intuition is that I probably created this table before and it was not completely cleared somehow. By explicitly saying DROP TABLE
I managed to reset the internal state somehow? But that is just my guess.
我的直觉是我之前可能创建了这个表,但它并没有以某种方式完全清除。通过明确地说DROP TABLE
我设法以某种方式重置内部状态?但这只是我的猜测。
In short, try DROP whatever table you are creating, and CREATE it again.
简而言之,尝试 DROP 您正在创建的任何表,然后再次创建它。
回答by Oswald
Column names must be unique in the table. You cannot have two columns named asd
in the same table.
列名在表中必须是唯一的。您不能asd
在同一个表中命名两个列。