MySQL 创建表后表不存在
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8142002/
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
Table doesn't exist after CREATE TABLE
提问by Julien G
I'm trying to import this sql in my database name symfony
我正在尝试在我的数据库名称 symfony 中导入此 sql
CREATE TABLE IF NOT EXISTS ingredient (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
and i get
我明白了
#1146 - Table 'symfony.ingredient' doesn't exist
This seems rather odd since i'm trying here to CREATE this table, so... why is it not working ? I've got the same problem if i try
这看起来很奇怪,因为我在这里尝试创建这个表,所以......为什么它不起作用?如果我尝试,我会遇到同样的问题
CREATE TABLE symfony.ingredient
Or the feature in symfony 2
或者 symfony 2 中的功能
c:\Dev\Symfony>php app/console doctrine:schema:create
PS: I have this problem only with the new version of xampp.
PS:我只有新版本的xampp才有这个问题。
EDIT
编辑
Well, i somehow managed to solve my problem. I dropped my database, then created one (not with the interface) and finally i restarded mysql service. I don't know why and how it unstuck me, but i hope this will help someone.
好吧,我以某种方式设法解决了我的问题。我删除了我的数据库,然后创建了一个(不是使用接口),最后我重新启动了 mysql 服务。我不知道为什么以及如何让我解脱,但我希望这会对某人有所帮助。
回答by Lexxtor
I had the same problem. My solution: Change table name in the create table query, exequte it and then rename the table.
我有同样的问题。我的解决方案:在创建表查询中更改表名,执行它然后重命名表。
Then, you can also drop this table and after it create it without getting error.
然后,您还可以删除此表,然后在创建它之后不会出错。
回答by jemont
What worked for me was:
对我有用的是:
- Going to the folder xampp/mysql/data/database-name/
- You'll see only the
.frm
file. The files.MYD
and.MYI
are missing for empty tables. - Delete the
.frm
file. - Stop MySQL process and restart it.
- After that I was able to create the table.
- 转到文件夹 xampp/mysql/data/database-name/
- 您只会看到
.frm
文件。空表缺少文件.MYD
和.MYI
。 - 删除
.frm
文件。 - 停止 MySQL 进程并重新启动它。
- 之后,我能够创建表。
The old version of xampp created tables in MyISAM format the new version as InnoDB!
旧版本的 xampp 以 MyISAM 格式创建表,新版本为 InnoDB!
回答by Mike
I had this same problem. I got a "server went away" message when creating the table and after that I was getting table doesn't exist messages, but I couldn't try to re-create the table because then I got a message saying that it didexist. I solved it by executing this at the command line:
我有同样的问题。我在创建表时收到“服务器消失”消息,之后我收到表不存在的消息,但我无法尝试重新创建表,因为我收到一条消息说它确实存在。我通过在命令行执行这个来解决它:
mysqlcheck --repair --all-databases -u root -p
It also wouldn't hurt to restart the mysql server after this as well just in case.
以防万一,在此之后重新启动 mysql 服务器也没有什么坏处。
回答by Owino
Go to the database in phpadmin and in sql drop the table .Then create the table.
转到 phpadmin 中的数据库并在 sql 中删除表。然后创建表。
回答by Traian
I had the same issue: #1146 - Table 'tutsplus_ci.posts' doesn't exist. I solved this issue following these steps:
我遇到了同样的问题:#1146 - 表 'tutsplus_ci.posts' 不存在。我按照以下步骤解决了这个问题:
I made an export of the incriminated table in a sql file. I noticed that the table name in the .sql file has a suplemental trailing space. I switch back to phpmyadmin in Operations section of my table and I rename the table from ' posts' to 'posts'. After taken all these actions the error didn't show up.
我在 sql 文件中导出了有罪表。我注意到 .sql 文件中的表名有一个补充的尾随空格。我在表的操作部分切换回 phpmyadmin,并将表从“posts”重命名为“posts”。采取所有这些措施后,错误没有出现。
To conclude, indeed the table 'posts' didn't exist as error message said. Because the the actual name of the table was ' posts' not 'posts'. The space before the name is hard to be notice in phpmyadmin. This is the story. Nothing special. I hope it helps!
总而言之,确实如错误消息所述,表“帖子”并不存在。因为表的实际名称是“posts”而不是“posts”。名称前的空格在 phpmyadmin 中很难被注意到。这就是故事。没什么特别的。我希望它有帮助!
回答by Tessmore
Hmm, are you sure you have a database and are priviledged to do CREATE statements.
嗯,您确定您有一个数据库并且有权执行 CREATE 语句。
If you have phpmyadmin:
如果您有 phpmyadmin:
To test the first possibiblity, create a new (empty) test database, click it in the menu and then press the SQL button in the top navigation and copy paste your statement again. If this doesn't work try the second.
要测试第一个可能性,请创建一个新的(空)测试数据库,在菜单中单击它,然后按顶部导航中的 SQL 按钮并再次复制粘贴您的语句。如果这不起作用,请尝试第二个。
For the second you can click on the 'home' button and then go to 'Privileges'. If there are only two or three accounts, but all with root privileges, you have the privileges to do a CREATE. Otherwise you can check your account and give yourself the privileges.
第二,您可以单击“主页”按钮,然后转到“权限”。如果只有两个或三个帐户,但都具有 root 权限,则您有权执行 CREATE。否则,您可以检查您的帐户并授予自己特权。
If both possibilities didn't work-out I don't know either. It worked fine for me :(
如果这两种可能性都不起作用,我也不知道。它对我来说很好:(