发布于 4年前

MySQL错误 check the manual that corresponds to your MySQL server version for the right syntax

创建数据库表时,报错 check the manual that corresponds to your MySQL server version for the right syntax

DROP TABLE IF EXISTS `users`;
CREATE TABLE `users` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  'name' varchar(10) NOT NULL,
  `time` int(10) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

问题分析:

一般报这个错误可以从以下几点找原因:

  • 中英文标点符号混淆,如: , ,
  • sql 关键词冲突,如: 把 desc 当做字段名;
  • MySQL 语法错误

而这里很明显这行代码中把 `打成 '了。

原代码:

'name' varchar(10) NOT NULL,

改为代码:

`name` varchar(10) NOT NULL,
©2020 edoou.com   京ICP备16001874号-3