Mysql - drop database with # in name

Solution 1:

You might have hidden folder in data directory. Please do a ls -larth and the remove mysql.backup directory.

By default any folders inside the mysql data directories will be read as database and will be shown in "show databases".

Solution 2:

You should always escape database names using backtick quotes, at least in case of doubt.

DROP DATABASE `#mysql50#mysql.backup`

Solution 3:

If the storage engine of the database is MYISAM just stop the database server and remove the directory named after your database in you data directory. (default var/lib/mysql)

Solution 4:

Any directory in MySQL datadir is considered as database by MySQL. Most likely you have dedicated mount point for /var/lib/mysql with ext{4,3,2} filesystem and default 'lost+found' directory present (lost+found directory is used by file system check tools (fsck)). You can say MySQL to treat this directory as directory and not database with the help of ignore_db_dir option in my.cnf:

ignore_db_dir=lost+found

In your particular (#mysql50#mysql.backup) case it would be:

ignore_db_dir=mysql.backup