Bug #461 dash both allowed and disallowed in database name
Submitted: 20 May 2003 10:27 Modified: 20 Jun 2006 21:40
Reporter: Vicki Brown Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version: OS:FreeBSD (FreeBSD)
Assigned to: CPU Architecture:Any

[20 May 2003 10:27] Vicki Brown
Description:
if I use
      mysqladmin -uroot -p****** create mambo-cfcl

I can create a database with a dash in the name

If, however, I use

   mysql -u root -p
   Enter password: *******

   mysql> delete database mambo-cfcl

I get:

ERROR 1064: You have an error in your SQL syntax near 'DATABSE mambo-cfcl' at line 1

How to repeat:
As above

Suggested fix:
Either both mysql and mysqladmin should allow the - or both should forbid it
[20 May 2003 10:33] Vicki Brown
Yes, I know that was a misspelled error message; here's a paste of a retest for clarity:

   mysql> delete database mambo-cfcl;
   ERROR 1064: You have an error in your SQL syntax near 'database mambo-cfcl' at line 1
[5 May 2006 18:22] Jon Bailey
You may need to put back-ticks around the database name -- such as:

drop database `mambo-cfcl`;
[15 Jun 2006 17:28] Tim Merkin
What that status of this?  I didn't know about this bug, and so I created a database with a dash in the name, and now I want to delete it.  Has this bug been fixed in the newest version of Mysql?  I am currently running version 4.1.20
[20 Jun 2006 21:40] Jim Winstead
Fixing status on this non-bug. You can drop a database with a dash in its name by using the correct syntax for dropping a database, and quoting the identifier.

  DROP DATABASE `name-with-dash`;
[21 Jul 2006 20:11] Tim Merkin
I was using the ticks to no avail, thats why I posted.  I still get the error:

mysql> drop database 'dbname-with-dash';
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 ''dbname-with-dash'' at line 1
mysql>
[21 Jul 2006 20:31] Jim Winstead
You are  using the wrong quote-marks. You want the backquote (`), not the single quote (').

On a US keyboard, the backquote is generally to the immediate left of the '1' key.
[13 Jan 2012 19:19] Andrea Soper
Adding tick marks is an effective work around, but maybe this should actually be fixed?

I can confirm it's also a problem on OS X.