Bug? #1146 - Table 'xxx.xxxxx' doesn't

2019-01-06 15:13发布

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?

18条回答
成全新的幸福
2楼-- · 2019-01-06 15:47

I got this issue after copying mytable.idb table file from another location. To fix this problem I did the following:

ALTER TABLE mydatabase.mytable DISCARD TABLESPACE;

Copy mytable.idb

ALTER TABLE mydatabase.mytable IMPORT TABLESPACE;

Restart MySql

查看更多
冷血范
3楼-- · 2019-01-06 15:51

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 as Notifications. 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.

查看更多
Lonely孤独者°
4楼-- · 2019-01-06 15:52

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!!

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!

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.

查看更多
狗以群分
5楼-- · 2019-01-06 15:55

In my case, MySQL's parameter; lower_case_table_names was configured = 0.

It causes queries related with using upper cases will not work.

查看更多
Juvenile、少年°
6楼-- · 2019-01-06 15:58

The reason I was facing this was because I had two "models.py" files which contained slightly different fields. I resolved it by:

  1. deleting one of the models.py files
  2. correcting references to the deleted file
  3. then running manage.py syncdb
查看更多
爱情/是我丢掉的垃圾
7楼-- · 2019-01-06 15:59

Restarting MySQL works fine for me.

查看更多
登录 后发表回答