Unable to Import Wordpress Site to Local 5.10.1 - ERROR 1146 (42S02) at line 1: Table 'local.wp_options' doesn't exist

Okay, so I figured it out. I’m really surprised to find out what the issue was, given how silly/stupid it is and that this tool didn’t have a way to manage it automatically. Especially since this tool is focused on Wordpress sites and making it easy. You would assume the import process would be the easy part.

Also, I saw another person post this same issue and the solution provided by someone else, although it works, it’s A LOT more effort and just a ridiculous approach as well.

So, here is the issue and the solution. In my case, I typically use a bash script to automate the backup job. In my bash script I use the following command:

mysqldump --force --opt --user=$USER -p$PASSWORD --databases $DB > DBbackup.sql

The issue is using the --databases parameter. Now, the reason I use this, is because that parameter will output two lines at the top of the backup.sql file.

  1. CREATE DATABASE (if does not exist) DATABASE_NAME
  2. USE DATABASE_NAME

Now, this is very useful, as I can easily just reimport that backup.sql and it will simply drop all tables and overwrite them into that database. I don’t need to do any prep, dropping tables or deleting and recreating the database, it doesn’t load into the wrong database, etc.

Very very handy.

So, after searching this forum and using google and coming up empty, I thought there must be something to do with that error code using “local.wp_options”. So I figured, maybe it’s because my database name is included in this backup.sql file. Sure enough, that was it. So I simplified my script to use only this:

mysqldump --user=$USER -p$PASSWORD $DB > DBbackup.sql

This will produce a database dump without the use and create database lines. Dropped my zip archive into local and bam, it worked.

So, anyway, there is the solution. If you found this and you were pulling out your hair, saying what the ***** is going on. You now have your solution. I hope you found this before you wasted too much time.

Now, my question to the developers of this fantastic tool. Why is there not an option to just ignore this by the import tool OR simply alert the user of this so that they can fix it. The error message is completely useless and doesn’t really help to identify the issue. Also, a simple how-to guide for new users covering this topic would also be great. I assume anyone that finds this tool, the first thing they will want to do is to import their live site. So that process should be painless and an enjoyable one. Like, wow! All I needed to do was drop a zip file with my wp-contents and mysqldump file. And I have a live working local website. This is amazing. Instead of a few hours thinking what the heck is going on!

Anyway, just giving my two cents worth and hoping this post gets indexed in google for those of you that search for this error in the future.

5 Likes