2011-06-23 55 views
0

我在我的“database_name”中创建了一个表license_serial。但是当我尝试创建名为license的第二个表时,它说它已经存在。
这是为什么?我的数据库只包含一个license_serial.frm和一个db.opt。在MySQL中创建表

mysql> SHOW TABLES; 
+---------------------+ 
| Tables_in_mobilemp3 | 
+---------------------+ 
| license_serial  | 
+---------------------+ 
1 row in set (0.00 sec) 

mysql> select * from license; 
ERROR 1146 (42S02): Table 'mobilemp3.license' doesn't exist 

创建第二表:

CREATE TABLE `license` (
`id` int(10) unsigned NOT NULL auto_increment, 
`serial_id` int(10) unsigned NOT NULL, 
`uid` bigint(20) unsigned NOT NULL, 
`active` tinyint(1) NOT NULL, 
`first_seen` timestamp NOT NULL default CURRENT_TIMESTAMP, 
`last_seen` timestamp NOT NULL, 
PRIMARY KEY (`id`), 
UNIQUE KEY `serial_uid` (`serial_id`,`uid`) 
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; 

提供了以下错误消息:

ERROR 1050 (42S01): Table 'mobilemp3.license' already exists 

编辑:

并将该溶液是这样(在该顺序):

drop database databasename; 
create database databasename; 
use databasename; 
+0

向我们展示命令的输出SHOW TABLES – babonk

+0

我读这篇文章http://stackoverflow.com/questions/3302476/mysql-1050-error-table-already-exists-when-in-fact-it-does不,但我没有得到解决方案,我删除了什么文件? – Kobe

+0

向我们展示如何“创建第二个表” –

回答

1

我能想到的唯一的事情是,表格是在以root身份登录,并且您正在使用的用户无权访问该表。在这种情况下,你不能从中选择(不知道它是否会被show tables命令过滤掉)

以root用户身份登录到该数据库并检查该表是否存在。

+0

我该如何检查? – Kobe

+0

以root身份登录并运行'show tables' –

+0

它给了我:“空集” – Kobe