Delete (Drop) MySQL database
It is very easy to drop a MySQL database:
drop database database_name
Tons of blogs and articles online mention this command. Recently, however, I came across a database name which had spaces in them. For example:
company balances electronics inventory store employees ...
If I do:
drop database company balances
MySQL would complain that the databases company and balances do not exists. Naturally, the first thought on my mind was to enclose them the database.
drop database 'company balances'
Once again MySQL complains about incorrect syntax. Using double quotes produces the same error. Every MySQL site and blog was giving drop database examples but not one documented a solution to this problem. After a bit of trial and error, I was finally able to drop the database. Following is the command:
$ mysqladmin -u root -p drop 'company balances'
Where 'company balances' is the name of the database.