MySQL Create Table Error - table does not exist

I am new to MySQL and I have a problem: if I try to create a table in my newly created โ€œrecommendโ€ database, I get the following error:

ERROR 1146 (42S02): Table "recommend. User" does not exist

I checked related posts here and on the Internet, but nothing helped. If I use the MySQL command line, I still get the same error.

SELECT DATABASE() FROM DUAL; +------------+ | DATABASE() | +------------+ | recommend | +------------+ 1 row in set (0.00 sec) 

but then when I ran this command:

 mysql> use recommend Database changed mysql> CREATE TABLE Users (UserName VARCHAR(20),password VARCHAR(20),PRIMARY KEY(UserName)); 

ERROR 1146 (42S02): Table "recommend. User" does not exist

I also tried using Navicat and still getting the same error :(

+7
mysql
source share
2 answers

This seems like a data dictionary problem. You can get more information by checking the error log. (See here for docs here ).

Perhaps you have a lost table. If so, the solution is to create a table with the same name in a different database and then copy the .frm file to the current database. Then you can DROP table, and the subsequent CREATE should be done. More information on resolving this issue can be found here.

+4
source share

I had the same problem. I really read this topic before I was lucky with a simple solution. I tried to reset my table and it worked, in your case your table: User:

DROP TABLE Users;

The table does not exist, so naturally MySQL complains:

Error code: 1051. Unknown table "Users"

But then I ran the CREATE TABLE statement again, and it worked. Hope others can check these works every time? Much easier than going to the error log, especially if you are not the largest database administrator / system administrator / hacker.

+8
source share

All Articles