special characters in mysql?

aaron.kyle asked:

When I created a mysql database, I named it using a hyphen, like aaron-kyle.

When I check the database, I see:

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| respect-joomla     |
+--------------------+

But I can’t delete the database.

The specific command I used was:

mysql> drop database respect-joomla;

The error:

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 '-joomla' at line 1

I also tried:

mysql> DROP DATABASE 'respect-joomla';

I get the same error:

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 ''respect-joomla'' at line 1

Are there special ways to write – in mysql (like space in the command line is ) ?

My answer:


Try something like:

DROP DATABASE `aaron-kyle`;

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.