dongzhenge2014
2017-04-29 17:22
浏览 204
已采纳

MySQL说:文档#1064你的SQL语法有错误[关闭]

I'm trying to move my eCommerce website I created my self from a WAMPSERVER localhost to my online host.
In order to move the database(which was working perfectly on my localhos), I export it as an sql file,Then I created a new database in my online server to import the database sql file.
The problem I get after hit import is this :

ErrorSQL query:

-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE  `users` (

 `UserID` INT( 11 ) NOT NULL COMMENT  'To Identify User',
 `Username` VARCHAR( 255 ) NOT NULL COMMENT  'Username To Login',
 `Password` VARCHAR( 255 ) NOT NULL COMMENT  'Password To Login',
 `Email` VARCHAR( 255 ) NOT NULL COMMENT  'User Email',
 `FullName` VARCHAR( 255 ) NOT NULL COMMENT  'User Full name',
 `GroupID` INT( 11 ) NOT NULL DEFAULT  '0' COMMENT
);

MySQL said: Documentation

#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 ')' at line 14

What is the problem ?

UPDATE : The problem solved after adding the comment, but I'm getting another error messages like this :

    Error
SQL query:

--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE  `users` MODIFY  `UserID` INT( 11 ) NOT NULL AUTO_INCREMENT ,
AUTO_INCREMENT =9 COMMENT  'To Identify User';


MySQL said: Documentation

#1075 - Incorrect table definition; there can be only one auto column and it must be defined as a key 

图片转代码服务由CSDN问答提供 功能建议

我正在尝试移动我的电子商务网站,我将自己从WAMPSERVER localhost创建到我的在线主机。 > 为了移动数据库(在我的localhos上完美运行),我将其导出为sql文件,然后我在我的在线服务器中创建了一个新数据库来导入数据库sql文件。
问题我 获得点击导入是这样的:

ErrorSQL查询:

   -  -------------  ------------------------------------------- \ N  -  \正  - 表`users`的表结构
  -  
CREATE TABLE`user`(
 
'UserID`INT(11)NOT NULL COMMENT'识别用户',
`用户名`VARCHAR(255)NOT NULL 评论'用户名登录',
`密码`VARCHAR(255)NOT NULL评论'登录密码',
`电子邮件`VARCHAR(255)NOT NULL评论'用户电子邮件',
`FullName` VARCHAR(255  )NOT NULL COMMENT'用户全名',
`GroupID`INT(11)NOT NULL DEFAULT'0'COMMENT 
); 
   
 
 

MySQL说: 文档

#1064 - 您的SQL语法出错; 检查与MySQL服务器版本对应的手册,以便在第14行附近使用正确的语法

有什么问题? \ n

更新: 添加评论后问题解决了,但是我收到了另一条错误消息:

  Error 
SQL query:
 \  n  -  
--表'用户'的AUTO_INCREMENT 
  -  
ALTER表`users`修改`UserID`INT(11)NOT NULL AUTO_INCREMENT,
AUTO_INCREMENT = 9评论'识别用户'; 
 
  
MySQL说:文档
 
#n75  - 表定义不正确; 只能有一个自动列,必须将其定义为键
   
 

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • douzhanbai9526 2017-04-29 17:26
    已采纳

    the problem is in the last line you need to set a COMMENT 'your comment ' or completely remove COMMENT

     CREATE TABLE  `users` (
    
     `UserID` INT( 11 ) NOT NULL COMMENT  'To Identify User',
     `Username` VARCHAR( 255 ) NOT NULL COMMENT  'Username To Login',
     `Password` VARCHAR( 255 ) NOT NULL COMMENT  'Password To Login',
     `Email` VARCHAR( 255 ) NOT NULL COMMENT  'User Email',
     `FullName` VARCHAR( 255 ) NOT NULL COMMENT  'User Full name',
     `GroupID` INT( 11 ) NOT NULL DEFAULT  '0' COMMENT 'group id'
    );
    
    已采纳该答案
    评论
    解决 无用
    打赏 举报
  • dtrhd2850 2017-04-29 17:24

    You miss the comment for the Last column. Add it

    --------------------------------------------------------
    --
    -- Table structure for table `users`
    --
    CREATE TABLE  `users` (
    
     `UserID` INT( 11 ) NOT NULL COMMENT  'To Identify User',
     `Username` VARCHAR( 255 ) NOT NULL COMMENT  'Username To Login',
     `Password` VARCHAR( 255 ) NOT NULL COMMENT  'Password To Login',
     `Email` VARCHAR( 255 ) NOT NULL COMMENT  'User Email',
     `FullName` VARCHAR( 255 ) NOT NULL COMMENT  'User Full name',
     `GroupID` INT( 11 ) NOT NULL DEFAULT  '0' COMMENT ''
    );
    

    or if you do not need it, remove the COMMENT keyword:

    --------------------------------------------------------
    --
    -- Table structure for table `users`
    --
    CREATE TABLE  `users` (
    
     `UserID` INT( 11 ) NOT NULL COMMENT  'To Identify User',
     `Username` VARCHAR( 255 ) NOT NULL COMMENT  'Username To Login',
     `Password` VARCHAR( 255 ) NOT NULL COMMENT  'Password To Login',
     `Email` VARCHAR( 255 ) NOT NULL COMMENT  'User Email',
     `FullName` VARCHAR( 255 ) NOT NULL COMMENT  'User Full name',
     `GroupID` INT( 11 ) NOT NULL DEFAULT  '0'
    );
    

    UPADTE:

    To alter the autoincrement you have to add a primary key. Complete syntax looks like:

    CREATE TABLE  `users` (
    
     `UserID` INT( 11 ) NOT NULL COMMENT  'To Identify User',
     `Username` VARCHAR( 255 ) NOT NULL COMMENT  'Username To Login',
     `Password` VARCHAR( 255 ) NOT NULL COMMENT  'Password To Login',
     `Email` VARCHAR( 255 ) NOT NULL COMMENT  'User Email',
     `FullName` VARCHAR( 255 ) NOT NULL COMMENT  'User Full name',
     `GroupID` INT( 11 ) NOT NULL DEFAULT  '0',
    PRIMARY Key (UserID)
    );
    
     ALTER TABLE users MODIFY UserID INT( 11 ) NOT NULL AUTO_INCREMENT COMMENT 'To Identify User';
     ALTER TABLE users AUTO_INCREMENT=9
    

    To test this see my SQLFIDDLE

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题