Fix for ERROR 1049 (42000): Unknown database…

I was trying to import a new database but kept getting this error ERROR 1049 (42000): Unknown database ‘MYDATABASE’, finally got it fixed… the error wasn’t with the syntax it was how I exported my database.

When I exported my database from phpmyadmin, I selected the main database rather than the individual tables. So in phpMyAdmin you’ll want to click on your database in the left column first.

Then click Export along the top tabs.

Select All tables in the database.


Check off the box for Structure and the following:

Add DROP TABLE / VIEW / PROCEDURE / FUNCTION / EVENT

Add IF NOT EXISTS

Add AUTO_INCREMENT value

Enclose table and field names with backquotes

Check the box for data and the following:

Complete inserts

Extended inserts

Maximal length of created query

Use hexadecimal for BLOB

Select “Insert” from drop box.


Check off the box “Save As File” and give your file a name, I like to use an uncompressed version of my database so I’m going to select “none” for that.

Press “Go” and you’ll see the SQL file start to download.

Back to Blog