mysql创建数据库时:ERROR 1064 (42000): You have an error in your SQL syntax;

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zp357252539/article/details/90700923

今天在mysql数据库中创建数据库时,报如下的错误:

mysql> CREATE DATABASE IF NOT EXISTS web-flash DEFAULT charset utf8 COLLATE utf8_general_ci;
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 '-flash DEFAULT charset utf8 COLLATE utf8_general_ci' at line 1
mysql> CREATE DATABASE IF NOT EXISTS web_flash DEFAULT charset utf8 COLLATE utf8_general_ci;
Query OK, 1 row affected (0.13 sec)

后来发现数据库名如果有特殊字符“-”,会有上面的提示,“-”改成“_”就可以了

猜你喜欢

转载自blog.csdn.net/zp357252539/article/details/90700923