Here is the simple, quick fix to the "#1046: No database selected" error when importing a .sql file from a Wamp installation in phpMyAdmin.
In phpMyAdmin, click the Export tab situated under Home instead of the one when you are viewing the database to export. This will allow you to export entire databases and not only the tables contained in it. This might not work for users of hosting sites such as Hostmonster or Hostgator, since they pick the database names for you.
- Create the database on your server and note down the name.
- Open your .sql file with a text editor. You might want to use something other than Notepad since it doesn't recognize the line breaks.
- Insert the following line before your first CREATE TABLE command in your .sql file:
Be careful to write in the right database name. Hostmonster users, for example, will have their username in front of their database name. Therefore, the products database is in fact named username_products.
- Save your .sql file and import it using the import tab in phpMyAdmin.