2013-02-01 104 views
1

我試圖使用phpMyAdmin恢復舊數據庫(從2009年開始)。我得到以下錯誤:恢復Mysql中的舊數據庫

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'not_null primary_key auto_increment, `Owned` int(11) not_null, `Owner` int' at line 2 

我GOOGLE了錯誤,但無法找到一個解決方案。我知道多年來MySQL發生了一些變化,但我應該怎麼做?

我的查詢如下:

CREATE TABLE `aautod` (
    `aAutoId` int(11) not_null primary_key auto_increment, 
    `Owned` int(11) not_null, 
    `Owner` int(11) not_null, 
    `Description` string(64) not_null, 
    `Model` int(11) not_null, 
    `Value` int(11) not_null, 
    `Locked` int(11) not_null, 
    `ColorOne` int(11) not_null, 
    `ColorTwo` int(11) not_null, 
    `License` string(100) not_null, 
    `Locationx` real(12) not_null, 
    `Locationy` real(12) not_null, 
    `Locationz` real(12) not_null, 
    `Angle` real(12) not_null, 
    `Parked` real(12) not_null, 
    `ParkLocationx` real(12) not_null, 
    `ParkLocationy` real(12) not_null, 
    `ParkLocationz` real(12) not_null, 
    `ParkAngle` real(12) not_null, 
    `GPS` int(11) not_null, 
    `Color1` int(11) not_null, 
    `Color2` int(11) not_nul, 
    PRIMARY KEY (`aAutoId`) 
) TYPE=MyISAM DEFAULT CHARSET=latin1; 
+1

not_null到'not null'和primary_key到'主鍵' – knightrider

回答

1

你有多個錯誤:

正如已經指出not_null應該not null。以及primary_key應該是primary key

我改變string(xx)varchar

http://dev.mysql.com/doc/refman/5.5/en//string-types.html

real(xx)有兩個參數,而不是1,第二個參數是地方多少小數小數點後。

http://dev.mysql.com/doc/refman/5.5/en/floating-point-types.html

type=MyISAM改爲Engine=MyIsam

您還定義了主鍵兩次,一次是在第一行的聲明,並在表聲明的最後一行。我改變了這個只聲明一次。

CREATE TABLE `aautod` (
`aAutoId` int(11) not null primary key auto_increment, 
`Owned` int(11) not null, 
`Owner` int(11) not null, 
`Description` varchar(64) not null, 
`Model` int(11) not null, 
`Value` int(11) not null, 
`Locked` int(11) not null, 
`ColorOne` int(11) not null, 
`ColorTwo` int(11) not null, 
`License` varchar(100) not null, 
`Locationx` real(12,11) not null, 
`Locationy` real(12,11) not null, 
`Locationz` real(12,11) not null, 
`Angle` real(12,11) not null, 
`Parked` real(12,11) not null, 
`ParkLocationx` real(12,11) not null, 
`ParkLocationy` real(12, 11) not null, 
`ParkLocationz` real(12, 11) not null, 
`ParkAngle` real(12, 11) not null, 
`GPS` int(11) not null, 
`Color1` int(11) not null, 
`Color2` int(11) not null 
) ENGINE=MyISAM DEFAULT CHARSET=latin1; 
+0

謝謝,我做了這些改變,但現在我得到了:#1064 - 你的SQL語法錯誤;請檢查與您的MySQL服務器版本相對應的手冊,以便在第35行''ENGINE = MyISAM DEFAULT CHARSET = latin1'附近使用正確的語法。 – user2033139

+0

您使用的是哪種版本的phpmyadmin和mysql?我只用phpmyadmin 3.4和MySQL 5.5運行查詢,它工作。它最可能的版本問題。嘗試改回它的類型MyISAM – Scott

+0

我的MySQL版本是5.1.66協議10和phpmyadmin是3.5.4,即使我改回它相同的錯誤。謝謝你的幫助。 – user2033139

0

它應該是兩個單獨的詞:NOT NULLPRIMARY KEY