How to DROP a database with character '?' in its name?

hugseirvak picture hugseirvak · Mar 27, 2011 · Viewed 17.6k times · Source

Just trying out ubuntu server on my pc and have been testing some commands including mysql. I'm not sure why phpMyAdmin permitted me to create a database like this 'testing?db'. I'm trying to drop this database via SSH but I get this error:

mysql> show databases
    -> ;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| phpmyadmin         |
| testing?db         |
| testing_db         |
| wp                 |
+--------------------+
6 rows in set (0.00 sec)

mysql> DROP DATABASE testing?db;
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 '?db' at line 1
mysql>

I tried creating a database with a '?' in it and it also gives me syntax error. via ssh. so how do I remove this database?

Answer

mvds picture mvds · Mar 27, 2011

Try:

DROP DATABASE `testing?db`;