I have exported a database from MySQL version 5.5.40, but when I am importing it to MySQL 5.5.44 I get an error regarding the syntax.
CREATE TABLE IF NOT EXISTS `key_value` (
`collection` varchar(128) CHARACTER SET ascii NOT NULL DEFAULT '' COMMENT 'A named collection of key and value pairs.'
`value` longblob NOT NULL COMMENT 'The value.',
PRIMARY KEY (`collection`,`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Generic key-value storage table. See the state system for…';
The error received is:
ERROR 1064 (42000): 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 '`value` longblob NOT NULL COMMENT 'The value.',
PRIMARY KEY (`collection`,`nam' at line 3
Please suggest.
The solution, per this comment in the drupal.org issue queue , is this:
Change this:
CREATE TABLE ``key_value`` ( ``collection`` varchar(128) CHARACTER SET ascii NOT NULL DEFAULT '' COMMENT 'A named collection of key and value pairs.' ``value`` longblob NOT NULL COMMENT 'The value.', PRIMARY KEY (``collection``,``name``) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Generic key-value storage table. See the state system for…'
to this:
CREATE TABLE ``key_value`` ( ``collection`` varchar(128) CHARACTER SET ascii NOT NULL DEFAULT '' COMMENT 'A named collection of key and value pairs.', ``name`` varchar(128) CHARACTER SET ascii NOT NULL DEFAULT '' COMMENT 'The key of the key-value pair. As KEY is a SQL reserved keyword, name was chosen instead.', ``value`` longblob NOT NULL COMMENT 'The value.', PRIMARY KEY (``collection``,``name``) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Generic key-value storage table. See the state system for';
then remove this near the end to prevent another error:
ALTER TABLE ``key_value`` ADD ``name`` varchar(128) CHARACTER SET ascii NOT NULL DEFAULT '' COMMENT 'The key of the key-value pair. As KEY is a SQL reserved keyword, name was chosen instead.';
There is no name
column in your table but you are creating your primary key with combination of PRIMARY KEY ( collection
, name
). So just remove name and try.
Also add ',' after collection column and before value column as suggested by Khalid.
Finally you can use -
CREATE TABLE IF NOT EXISTS `key_value` (
`collection` VARCHAR(128) CHARACTER SET ASCII NOT NULL DEFAULT '' COMMENT 'A named collection of key and value pairs.',
`value` LONGBLOB NOT NULL COMMENT 'The value.',
PRIMARY KEY (`collection`)
) ENGINE=INNODB DEFAULT CHARSET=utf8mb4 COMMENT='Generic key-value storage table. See the state system for…';
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.