漏洞? #1146 - 表“xxx.xxxxx”不存在
我使用的是Windows XP。我正在使用 phpMyAdmin 内置的创建表功能创建一个表, 我的数据库名称是ddd
。
它生成以下代码:
CREATE TABLE `ddd`.`mwrevision` (
`asd` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`sddd` INT NOT NULL
) ENGINE = INNODB;
并显示以下错误:
MySQL said:
#1146 - Table 'ddd.mwrevision' doesn't exist
可能是什么问题?
I am using windows XP. I am creating a table in phpMyAdmin using its built-in create table feature,
my database name is 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(20)
我过去也遇到过同样的问题。所有这些都是在将数据库文件移动到新位置并更新 mysql 服务器之后发生的。所有带有 InnoDB 引擎的表都从我的数据库中消失了。我试图重新创建它们,但 mysql 告诉我
1146:表'xxx'不存在
一直,直到我重新创建数据库并重新启动 mysql 服务。我认为有必要阅读有关 InnoDB 表二进制文件的信息。
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.I think there's a need to read about InnoDB table binaries.
我遇到了同样的问题,并且无法通过网络获得有关此问题的良好提示,因此我将其分享给您和所有需要的人。
在我的情况下,我将数据库(所有文件:frm、myd)复制到 MySQL 数据文件夹中的数据文件夹(在家使用 Wamp)。一切正常,直到我想创建一个表并出现错误
#1146 Table '...' does not exit!
。我使用 Wamp 2.1 和 MySQL 版本 5.5.16。
我的解决方案:
将数据库导出到文件;
验证导出的文件是否正确!!;
删除我有问题的数据库;
创建一个与上次同名的新数据库;
将文件导入到数据库。
对我来说问题已经解决了。现在我可以再次创建表而不会出现错误。
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!
.I use Wamp 2.1 with MySQL version 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.
重新启动 MySQL 对我来说效果很好。
Restarting MySQL works fine for me.
就我而言,即使该表在 PhpMyAdmin 中不可见,我也运行此命令:
DROP TABLE mytable
then
CREATE TABLE....
为我工作!
In my case I ran this command even if the table wasn't visible in PhpMyAdmin :
DROP TABLE mytable
then
CREATE TABLE....
Worked for me !
检查文件名。
您可能需要在 phpmyadmin 中创建一个与您尝试导入的数据库相匹配的新数据库。
Check filenames.
You might need to create a new database in phpmyadmin that matches the database you're trying to import.
我也有同样的问题。我尝试在mysql中创建一个表并得到同样的错误。我重新启动 mysql 服务器并运行命令,并能够在重新启动后创建/迁移表。
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.
今天我面临着同样的问题。我处于非常困难的情况,但是我创建了一个具有不同名称的表,例如(modulemaster 没有创建,然后我创建了 modulemaster1),创建表后我只是重命名表。
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.
我今天遇到了同样的问题。我试图创建一个表
users
,并被提示ERROR 1146 (42S02): Table users does not Exist
,这没有任何意义,因为我是只是想创建表格!然后,我尝试通过输入“DROP TABLE users”来删除该表,因为我知道它会失败,因为它不存在,并且我收到了一个错误,提示“未知表用户”。收到此错误后,我再次尝试创建表,神奇的是,它成功创建了表!
我的直觉是,我之前可能创建了这个表,但不知何故它并没有完全清除。通过明确地说
DROP TABLE
我设法以某种方式重置内部状态?但这只是我的猜测。简而言之,尝试删除您正在创建的任何表,然后再次创建它。
I encountered the same problem today. I was trying to create a table
users
, and was prompted thatERROR 1146 (42S02): Table users doesn't exist
, which did not make any sense, because I was just trying to create the table!!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, sayingUnknown table users
. After getting this error, I tried to create the table again, and magically, it successfully created the table!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.In short, try DROP whatever table you are creating, and CREATE it again.
正如 pprakash 上面提到的,复制 table.frm 文件 和 ibdata1 文件对我有用。
简而言之:
之后,一切都很好。 (如果成功了,别忘了备份!)
As pprakash mentions above, copying the table.frm files AND the ibdata1 file was what worked for me.
In short:
After that, all was well. (Don't forget to backup if you have success!)
列名在表中必须是唯一的。同一个表中不能有两个名为
asd
的列。Column names must be unique in the table. You cannot have two columns named
asd
in the same table.从 CMD 运行%path%=设置为 mysql/bin
mysql_upgrade -u user -ppassword
run from CMD & %path%=set to mysql/bin
mysql_upgrade -u user -ppassword
最近我遇到了同样的问题,但是是在 Linux 服务器上。数据库崩溃了,我通过简单地复制
/var/lib/mysql/*
(wamp 中的模拟 mysql DATA 文件夹)从备份中恢复了它。恢复后,我必须创建新表并收到 mysql 错误#1146。我尝试重启mysql,却说无法启动。我检查了mysql日志,发现mysql根本没有访问其数据库文件的权限。我检查了 /var/lib/mysql/* 的所有者信息,并得到了'myuser:myuser'
(myuser 是我)。但它应该是'mysql:adm'
(也是自己的开发者机器),所以我将所有者更改为'mysql:adm'。 mysql正常启动后,我可以创建表,或执行任何其他操作。因此,在移动数据库文件或从备份恢复后,请检查 mysql 的访问权限。
希望这有帮助...
Recently I had same problem, but on Linux Server. Database was crashed, and I recovered it from backup, based on simply copying
/var/lib/mysql/*
(analog mysql DATA folder in wamp). After recovery I had to create new table and got mysql error #1146. I tried to restart mysql, and it said it could not start. I checked mysql logs, and found that mysql simply had no access rigths to its DB files. I checked owner info of /var/lib/mysql/*, and got'myuser:myuser'
(myuser is me). But it should be'mysql:adm'
(so is own developer machine), so I changed owner to 'mysql:adm'. And after this mysql started normally, and I could create tables, or do any other operations.So after moving database files or restoring from backups check access rigths for mysql.
Hope this helps...
我面临这个问题的原因是因为我有两个“models.py”文件,其中包含略有不同的字段。
我通过以下方法解决了这个问题:
The reason I was facing this was because I had two "models.py" files which contained slightly different fields.
I resolved it by:
从另一个位置复制 mytable.idb 表文件后,我遇到了这个问题。为了解决这个问题,我执行了以下操作:
复制 mytable.idb
重新启动 MySql
I got this issue after copying mytable.idb table file from another location. To fix this problem I did the following:
Copy mytable.idb
Restart MySql
我有同样的问题。它是在 Windows 启动错误后发生的,似乎某些文件因此而损坏。我确实从保存的脚本中再次导入了数据库,并且工作正常。
I had the same issue. It happened after windows start up error, it seems some files got corrupted due to this. I did import the DB again from the saved script and it works fine.
我遇到这个问题是因为触发器不起作用。删除触发器后工作正常。
I had this problem because of a trigger not working..Worked after I deleted the trigger.
就我而言,MySQL 的参数;
lower_case_table_names
配置为= 0
。它会导致与使用大写字母相关的查询不起作用。
In my case, MySQL's parameter;
lower_case_table_names
was configured= 0
.It causes queries related with using upper cases will not work.
对我来说这是一个表名大小写问题。我必须确保表案例名称在删除查询中匹配,表
notifications
与Notifications
不同。我通过将表名大小写与查询以及 MySQLWorkbench 报告的内容相匹配来修复它。奇怪的是这个错误出现在一个有效的sql语句中。不知道是什么导致了这种区分大小写的情况。也许是自动 AWS RDS 更新。
For me it was a table name upper/lower case issue. I had to make sure that table case name matched in a delete query, table
notifications
was not the same asNotifications
. I fixed it by matching table name case with query and what MySQLWorkbench reported.What is wierd is that this error showed up in a worked sql statement. Don't know what caused this case sensitivity. Perhaps an auto AWS RDS update.
如果您正在修改 mysql bin->data dir's,之后,您的数据库导入将无法工作
因此您需要关闭 wamp,然后启动 wamp
现在数据库导入将正常工作
if you are modifying mysql bin->data dir's and after that, your database import will not works
so you need to close wamp and after that start wamp
now database import will work fine
确保您没有尝试对错误中提到的表执行某些操作的触发器。我收到
错误代码:1146。在对生产数据库中的另一个表进行插入查询时,表“exampledb.sys_diagnotics”不存在
。我导出了生产数据库的表模式,然后搜索模式 SQL 的exampledb.sys_diagnotics
实例,并找到了一条调试插入语句,我已将其添加到开发环境中的表触发器中,但该调试语句已被复制到生产中。我的生产数据库中不存在exampledb.sys_diagnotics
表。通过删除表触发器中的调试语句解决了该错误。Make sure you do not have a trigger that is trying to do something with the table mentioned in the error. I was receiving
Error Code: 1146. Table 'exampledb.sys_diagnotics' doesn't exist
on insert queries to another table in my production database. I exported the table schemas of my production database then searched for instances ofexampledb.sys_diagnotics
the schema SQL and found a debugging insert statement I had added to a table trigger in my development environment but this debug statement had been copied to production. Theexampledb.sys_diagnotics
table was not present on my production database. The error was resolved by removing the debug statement in my table trigger.