Database cannot be deleted -- SQL Error 1049: Unknown database

WaveLength's profile image WaveLength posted 11 years ago in General Permalink
When I go to localhost, a database called test1 is listed in the left panel. I want to drop it, but when I click on it, I get this error message:

SQL Error (1049): Unknown database test1

If I run

drop database test1

then I get error 1008 ("database doesn't exist")

I have several of these fantom databases, and I'd like to delete them. Is there any way to do that?

Thanks.


ansgar's profile image ansgar posted 11 years ago Permalink
Do these databases show up in a SHOW DATABASES query result?
WaveLength's profile image WaveLength posted 11 years ago Permalink
No, they do not appear after a SHOW DATABASES query.
WaveLength's profile image WaveLength posted 11 years ago Permalink
I solved the problem, as follows:

Open the Session Manager, select localhost, choose an individual database from the Databases drop-down list, click save, click cancel, exit HeidiSQL, reopen HeidiSQL, select localhost, click Open. The phantom databases are gone.
ansgar's profile image ansgar posted 11 years ago Permalink
Very strange. Where do you think did they appear from?
[expired user #8616]'s profile image [expired user #8616] posted 8 years ago Permalink

thanx WaveLenght, after 3 years, it still is the same problem with the same solution.

ansgar's profile image ansgar posted 8 years ago Permalink

Can somebody please shed some light on where these phantom databases come from??

[expired user #8616]'s profile image [expired user #8616] posted 8 years ago Permalink

Ansgar, The db's are your own old db's . So the check for existing db's should be done with the connect and the problem is solved. But while there is no report button.

WILL ANY ONE TAKE THIS TO THE ISSUE LIST THANX

ansgar's profile image ansgar posted 8 years ago Permalink

Ansgar, The db's are your own old db's

Please explain.

[expired user #9653]'s profile image [expired user #9653] posted 8 years ago Permalink

I accidentally didn't set my new db to utf8_general_ci before saving. So I made another that was like that before continuing (with the tutorial I was watching). But then I wanted to get rid of the useless one so I went to delete it but got this same error. Playing around with stuff I found that in the session manager there is a field that shows what things it intends to load up under a given project (individual items separated by semi-colons within that field). I saw the two that I wanted and in between them the one that I didn't. So I highlighted it and removed it (and its semi-colon) from that list. and when I went to open it asked me to save the change, which I did. The project opened with out the part I didn't want and things have gone smoothly thus far from there.

FYI: I have absolutely no idea what I am doing (Youtube tutorials are what get me through) but it seems like my problem was similar, and my problem seems to be resolved, so hopefully that is helpful.

[expired user #9804]'s profile image [expired user #9804] posted 8 years ago Permalink

Had this issue except the phantom database would appear in a SHOW DATABASES query.

mysql> SHOW DATABASES;

+--------------------+
| Database           |
+--------------------+
| information_schema |
|  phantom_database  |
| another_database   |
+--------------------+

Notice there is a space in the database name (not sure how it got there, I dropped and recreated the database so it may have been a typo) seemed to be what was preventing HeidiSQL from deleting the database. From the CLI, single quotes and escape characters would not work for the DROP command, only backticks:

DROP DATABASE ` phantom_database`;

Please login to leave a reply, or register at first.