MYSQL建表错误:ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that ..near

在MySQL命令行使用sql语句进行建表时,MySQL 报错:

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 ''Silver Bullet' DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci' at line 1

 

错误输入:mysql> CREATE DATABASE 'Silver Bullet' DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;

看似没有问题,查找https://dev.mysql.com/doc/refman/5.5/en/keywords.html

发现为了区别MySQL的关键字与普通字符,MySQL引入了一个反引号。 

 

在上述的sql语句中,列名称使用的是单引号而不是反引号,所以会就报了这个错误出来。修改后

mysql> CREATE DATABASE `Silver Bullet` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;

熟悉的

你可能感兴趣的:(linux,mysql)