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

今天在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)

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

 

 

你可能感兴趣的:(数据库)