2011-06-23 63 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