Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I recently did a clean install of Linux Mint 16 Petra on my laptop.

Before I wiped the old system, I did a backup of all my MySQL databases by going to the Export tab in phpMyAdmin and dumping all the databases into one file. I didn't use any compression.

Now, on the new system, in phpMyAdmin, when I go to the Import tab and try to upload the SQL file, I get this error:

#1046 - No database selected

... Of course no database is selected, I am trying to restore them.

I am not at all an expert in MySQL, I use it to support my web design projects, so I don't understand why this isn't working. It seems to me phpMyAdmin should be able to read from a file that phpMyAdmin created.

How do I restore my databases from the SQL dump file that I created?

share|improve this question
Look into your dumped file and see if there is any create database if not exist mysql ... or similar lines. The dump should contain the data itself. – val0x00ff Nov 27 '13 at 13:18

It seems that your dump does not have the informations to create the database. Create the database first, then import the dump in that database.

share|improve this answer
The database file represents multiple databases. A dozen or so. I'm not sure I remember exactly what their names are. Is there no way to fix this with more of a batch process? – Questioner Nov 27 '13 at 13:24
If there's no CREATE DATABASE IF NOT EXIST in your dump file, and if the old databases has been removed, then you have to re-create them by hand. – Vinz Nov 27 '13 at 13:36
up vote 1 down vote accepted

The solution I used was to search the SQL file for everywhere that this text existed:

-- Database: `my_database_01`

And right under it, add the following lines:

USE `my_database_01`;

I did this for each database in the SQL dump file, and then I was able to import and restore all databases using phpMyAdmin's import command.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.