2013-02-01 106 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