mySQL 1046 error when importing wordpress database

15,638

Solution 1

Like the two other answers say: I wasn't importing the backup file to a particular database. I had to create a new database and upload the file to that, and it worked fine.

Solution 2

Try sticking a use statement in front of it:

USE MyWordpressDBName;
DROP TABLE IF EXISTS `wp_commentmeta` ;

MySql Use Reference

Solution 3

You posted a link describing how to backup your database. But the problem you have is not with the backup but with the restore, so you should look at the instructions on how to restore your database.

Luckily that site also has instructions on how to restore a database from a backup (any guide which only tells you how to backup but not how to restore is IMHO a waste of time). Try following the instructions on this page:

http://codex.wordpress.org/Restoring_Your_Database_From_Backup

In particular notice this command near the end of the tutorial:

mysql -h mysqlhostserver -u mysqlusername -p databasename < blog.bak.sql

The database name must be specified.

Share:
15,638
HandiworkNYC.com
Author by

HandiworkNYC.com

I make custom WordPress themes http://handiworknyc.com

Updated on June 22, 2022

Comments

  • HandiworkNYC.com
    HandiworkNYC.com almost 2 years

    I'm moving a locally developed wordpress site to a client's server so I'm trying to export the local database and import it to the server. I exported the .sql file according to the instructions here http://codex.wordpress.org/Backing_Up_Your_Database but I keep getting this error when importing:

    DROP TABLE IF EXISTS `wp_commentmeta` ;
    
    MySQL said: Documentation
    #1046 - No database selected 
    

    Any help very much appreciated. Thanks!