简体   繁体   中英

What is wrong in this MySQL syntax?

What is wrong here?

I exported this table from my local pma and trying to upload it on remote sever.

CREATE TABLE IF NOT EXISTS `posts` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `banna` text COLLATE utf8_croatian_ci,
  `bannb` text COLLATE utf8_croatian_ci,
  `img` varchar(255) COLLATE utf8_croatian_ci DEFAULT NULL,
  `images` text COLLATE utf8_croatian_ci,
  `title` varchar(255) COLLATE utf8_croatian_ci DEFAULT NULL,
  `subtitle` varchar(255) COLLATE utf8_croatian_ci DEFAULT NULL,
  `story` mediumtext COLLATE utf8_croatian_ci,
  `status` varchar(255) COLLATE utf8_croatian_ci DEFAULT NULL,
  `tags` varchar(255) COLLATE utf8_croatian_ci DEFAULT NULL,
  `auth` varchar(255) COLLATE utf8_croatian_ci DEFAULT NULL,
  `moder` varchar(255) COLLATE utf8_croatian_ci DEFAULT NULL,
  `linked` json DEFAULT NULL,
  `inde` int(11) DEFAULT NULL,
  `count` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=382 DEFAULT CHARSET=utf8 COLLATE=utf8_croatian_ci

Error:

#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 'json DEFAULT NULL,
  `inde` int(11) DEFAULT NULL,
  `count` int(11) DEFAULT NULL' at line 15

I have run your query on mysql version 5.7.21, it works fine, No error thrown, so it seems to me mysql version related issue raised in your site, here is the execution result

CREATE TABLE IF NOT EXISTS `posts` (
  `id`       bigint(20) NOT NULL                   AUTO_INCREMENT,
  `date`     datetime   NOT NULL                   DEFAULT CURRENT_TIMESTAMP,
  `banna`    text COLLATE utf8_croatian_ci,
  `bannb`    text COLLATE utf8_croatian_ci,
  `img`      varchar(255) COLLATE utf8_croatian_ci DEFAULT NULL,
  `images`   text COLLATE utf8_croatian_ci,
  `title`    varchar(255) COLLATE utf8_croatian_ci DEFAULT NULL,
  `subtitle` varchar(255) COLLATE utf8_croatian_ci DEFAULT NULL,
  `story`    mediumtext COLLATE utf8_croatian_ci,
  `status`   varchar(255) COLLATE utf8_croatian_ci DEFAULT NULL,
  `tags`     varchar(255) COLLATE utf8_croatian_ci DEFAULT NULL,
  `auth`     varchar(255) COLLATE utf8_croatian_ci DEFAULT NULL,
  `moder`    varchar(255) COLLATE utf8_croatian_ci DEFAULT NULL,
  `linked`   json                                  DEFAULT NULL,
  `inde`     int(11)                               DEFAULT NULL,
  `count`    int(11)                               DEFAULT NULL,
  PRIMARY KEY (`id`)
)
  ENGINE = InnoDB
  AUTO_INCREMENT = 382
  DEFAULT CHARSET = utf8
  COLLATE = utf8_croatian_ci

0 row(s) affected 1.535 sec

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM