17

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?

1 Answer 1

61

Try:

DROP DATABASE `testing?db`;
Sign up to request clarification or add additional context in comments.

6 Comments

yes, you can escape your table/fields name with a ` character
I was going to post the same thing. Nice.
It's called the backtick, present on any keyboard, but not in a fixed location. Look somewhere to the top or bottom left.
oh thanks! :) i've been using the computer for as long as i can remember but never noticed this backtick character on my keyboard.
@Jasmine I think not, the lsqo is a quotation character, while the backtick is actually an accent (fileformat.info/info/unicode/char/0060/index.htm)
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.