Title: Error importing from .sql database
Last modified: November 29, 2019

---

# Error importing from .sql database

 *  [DevonTT](https://wordpress.org/support/users/devontt/)
 * (@devontt)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/error-importing-from-sql-database/)
 * A friend had a WordPress site that went literally months without any updates.
   Eventually a vulnerability was exploited and his site was shut down by the hosting
   service for spam. He kind of gave up on it. After the hosting service restored
   access, I got a database error trying to access WP admin. I figured the old version(
   no clue what the site was running three years ago) was just too outdated to work
   anymore
 * So I installed the current version of WordPress at his domain and now I’m trying
   to restore the site from the old .sql file. I created a new .sql database and
   am trying to import from the old one. I keep getting errors that certain tables
   already exist, and the import does not finish. There is no .xml file from the
   old install to import via the dashboard.
 * Any ideas?

Viewing 12 replies - 1 through 12 (of 12 total)

 *  Moderator [James Huff](https://wordpress.org/support/users/macmanx/)
 * (@macmanx)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/error-importing-from-sql-database/#post-12189972)
 * Do the steps here help? [https://wordpress.org/support/article/restoring-your-database-from-backup/](https://wordpress.org/support/article/restoring-your-database-from-backup/)
 *  Thread Starter [DevonTT](https://wordpress.org/support/users/devontt/)
 * (@devontt)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/error-importing-from-sql-database/#post-12190608)
 * Yes, I did those steps and got an error, which led me here: “If you get an error
   message, your best bet is to post to the WordPress support forums to get help.”
 *  Thread Starter [DevonTT](https://wordpress.org/support/users/devontt/)
 * (@devontt)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/error-importing-from-sql-database/#post-12190611)
 * Here is the error I got when trying to import the database:
 * Error
    SQL query:
 * —
    — Database: `michaelb_wpmb` —
 * — ——————————————————–
 * —
    — Table structure for table `wp_comments` —
 * CREATE TABLE `wp_comments` (
    `comment_ID` bigint(20) UNSIGNED NOT NULL, `comment_post_ID`
   bigint(20) UNSIGNED NOT NULL DEFAULT ‘0’, `comment_author` tinytext COLLATE utf8mb4_unicode_ci
   NOT NULL, `comment_author_email` varchar(100) COLLATE utf8mb4_unicode_ci NOT 
   NULL DEFAULT ”, `comment_author_url` varchar(200) COLLATE utf8mb4_unicode_ci 
   NOT NULL DEFAULT ”, `comment_author_IP` varchar(100) COLLATE utf8mb4_unicode_ci
   NOT NULL DEFAULT ”, `comment_date` datetime NOT NULL DEFAULT ‘0000-00-00 00:00:
   00’, `comment_date_gmt` datetime NOT NULL DEFAULT ‘0000-00-00 00:00:00’, `comment_content`
   text COLLATE utf8mb4_unicode_ci NOT NULL, `comment_karma` int(11) NOT NULL DEFAULT‘
   0’, `comment_approved` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT‘
   1’, `comment_agent` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFA[…] 
   MySQL said: Documentation
 * #1050 – Table ‘wp_comments’ already exists
 *  Moderator [James Huff](https://wordpress.org/support/users/macmanx/)
 * (@macmanx)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/error-importing-from-sql-database/#post-12190694)
 * That’s odd, did the table already exist before you started the import? Also, 
   how did you generate the backup?
 *  Thread Starter [DevonTT](https://wordpress.org/support/users/devontt/)
 * (@devontt)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/error-importing-from-sql-database/#post-12191411)
 * The table that existed is in the .sql file from when the site was active three
   years ago. I assume these are typical tables for even old WP installations.
 *  Thread Starter [DevonTT](https://wordpress.org/support/users/devontt/)
 * (@devontt)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/error-importing-from-sql-database/#post-12191480)
 * Well, I just tried exporting the .sql database as an .xml file, then importing
   it into WP using the Import tool. I got this message:
 * Sorry, there has been an error.
    This does not appear to be a WXR file, missing/
   invalid WXR version number
 *  Moderator [James Huff](https://wordpress.org/support/users/macmanx/)
 * (@macmanx)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/error-importing-from-sql-database/#post-12192303)
 * Right, changing the file extension does also change it into a WordPress export
   file. You can only generate that from within a WordPress site’s Dashboard.
 * What I meant earlier was, do tables already exist in the database you’re importing
   this to?
 *  Thread Starter [DevonTT](https://wordpress.org/support/users/devontt/)
 * (@devontt)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/error-importing-from-sql-database/#post-12192307)
 * Yes, the table I’m importing into is the database created by the new WP installation.
 *  Moderator [James Huff](https://wordpress.org/support/users/macmanx/)
 * (@macmanx)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/error-importing-from-sql-database/#post-12192339)
 * Ah! That’s the problem. 🙂
 * Since you’re importing a whole WordPress database, you don’t need the tables 
   created by the existing new WordPress database.
 * So (assuming this new installation is bare with no content), delete those newly
   created tables, and import your database.
 *  Thread Starter [DevonTT](https://wordpress.org/support/users/devontt/)
 * (@devontt)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/error-importing-from-sql-database/#post-12192480)
 * So, delete all the tables in the new database?
 *  Moderator [James Huff](https://wordpress.org/support/users/macmanx/)
 * (@macmanx)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/error-importing-from-sql-database/#post-12192503)
 * Assuming this new installation is bare with no content, yes.
 * Then import the new database.
 *  Thread Starter [DevonTT](https://wordpress.org/support/users/devontt/)
 * (@devontt)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/error-importing-from-sql-database/#post-12192523)
 * OK, I’ll give that a try, thanks!

Viewing 12 replies - 1 through 12 (of 12 total)

The topic ‘Error importing from .sql database’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 12 replies
 * 2 participants
 * Last reply from: [DevonTT](https://wordpress.org/support/users/devontt/)
 * Last activity: [6 years, 6 months ago](https://wordpress.org/support/topic/error-importing-from-sql-database/#post-12192523)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
