MySQL: You have an error in your SQL syntax

Sometimes we have an error If we use a symbol – in database name or username:

MariaDB [(none)]> create database example-db;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '-db' at line 1

 

Solved this problem, need to add ` symbols to  database name or username:

MariaDB [(none)]> create database `example-db`; 
Query OK, 1 row affected (0.000 sec)

 

Click to rate this post!
[Total: 0 Average: 0]