Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
648 views
in Technique[技术] by (71.8m points)

database - MySQL server version for the right syntax to use near '' at line 3

I have some problem in PHPMyadmin when I import my DB.

CREATE TABLE IF NOT EXISTS `wp_cf_forms` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `form_id` varchar(18) COLLATE utf8_general_ci; NOT NULL DEFAULT '',
  `type` varchar(255) COLLATE utf8_general_ci; NOT NULL DEFAULT '',
  `config` longtext COLLATE utf8_general_ci; NOT NULL,
  PRIMARY KEY (`id`),
  KEY `form_id` (`form_id`)
)

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 3(`form_id` varchar(18) COLLATE utf8_general_ci; NOT NULL DEFAULT '',)

Has anyone any idea how I can solve this?

question from:https://stackoverflow.com/questions/66068304/mysql-server-version-for-the-right-syntax-to-use-near-at-line-3

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

from what said @Thorsten Kettner you can solve this problem doing

CREATE DATABASE mydatabase CHARACTER SET utf8 COLLATE utf8_general_ci;

USE mydatabase;

CREATE TABLE IF NOT EXISTS `wp_cf_forms` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `form_id` varchar(18) NOT NULL DEFAULT '',
  `type` varchar(255) NOT NULL DEFAULT '',
  `config` longtext NOT NULL,
  PRIMARY KEY (`id`),
  KEY `form_id` (`form_id`)
);

the result

mysql> CREATE DATABASE mydatabase CHARACTER SET utf8 COLLATE utf8_general_ci;
Query OK, 1 row affected (0.02 sec)

mysql> USE mydatabase;
Database changed
mysql> CREATE TABLE IF NOT EXISTS `wp_cf_forms` (
    ->   `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
    ->   `form_id` varchar(18) NOT NULL DEFAULT '',
    ->   `type` varchar(255) NOT NULL DEFAULT '',
    ->   `config` longtext NOT NULL,
    ->   PRIMARY KEY (`id`),
    ->   KEY `form_id` (`form_id`)
    -> );
Query OK, 0 rows affected (0.03 sec)

mysql> SHOW TABLES ;
+----------------------+
| Tables_in_mydatabase |
+----------------------+
| wp_cf_forms          |
+----------------------+
1 row in set (0.01 sec)

mysql>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...