Steve Zoe
4 min readMar 23, 2020

--

So, while doing some house cleaning on my site last night, I deleted about the most important table on my wordpress database — wp_options table.

So the “wp_options” table is about the most important table in your wordpress database, it houses virtually every information saved on your website, this is the brain box of your database, it houses the neural network of your site itself.

Unlike other tables in your database that houses the content on your site, this standalone table (the only one of its kind) stores different kind of data from the other tables, it stores data about the site itself. It stores all data related to the setup and administration of your site as a whole. — Yup! It’s a very important table in your DB, and you really don’t wanna mess with it.

So being the usual {breakThings} me, I pressed some buttons and deleted the table! Which is what I guess you just did as well?

So after panicking for some minutes and some gulps of monster drink, the {fixThings} part of me came alive, and I was able to come up with a simple yet efficient way to diffuse the whole issue, and that process is what I’m going to be sharing with you, if you are in the same situation I was last night…

  • FTP into your wordpress root folder, edit your wp-config.php file. Change your table prefix to something different.

Usually, the table prefix statement is something like this:

So if my table prefix before was “vkh_” , I’d change it to something else like “mmg_” 🤷🏻‍♂️ — You get the idea right?

  • Head back to your browser and visit your site url, you should see a fresh install wordpress page
  • Follow through on the installation and create a new admin user.
    Login to the backend, now you can access all your plugins, your themes, and even your images.. But no content — Posts, pages, comments.. all gone.

So what you have now is all your files, but no data. Let’s go get back the data (At least, the ones we can get back…)

  • Head over to your database — My goto tool would be “phpmyadmin”. But you can as well use any db tool you’re comfortable with. You should see a new set of tables from the newly installed wordpress — they should start with the new prefix you just changed into. In my case, “mmg_”

Make a backup of your current database, incase anything goes wrong

  • Select and Drop/Delete all the tables for the newly installed wordpress site. In my case, that would be all the table prefixed with “mmg_”

EXCEPT FOR

  • - (a) mmg_options
  • - (b) mmg_users
  • - © mmg_usermeta
  • Rename all the tables from the old install. In my case, that would be all the tables that are prefixed with “vkh_” — to the new prefix “mmg_”

EXCEPT FOR

  • - (a) vkh_options
  • - (b) vkh_users
  • - © vkh_usermeta
  • Once you’ve done this, you should have all your contents back. Login to your wordpress backend, with the new user account login details. You should see all your pages, posts. But the only downside is that you’ll have to reconfigure some of your plugins all over.

However, to save yourself from all these trouble and stress… It’s a good advice to always have a daily site backup in place on your site. I learnt the hard/stressful way.

Now I have a daily backup in place on my site as I do on my other projects.

I hope this article is helpful. If you do have any questions or you have a better way than this, be kind enough to share in the comments section.

Cheers 🍻

--

--

Steve Zoe

Innovative frontend engineer with 6+ years leading teams, crafting efficient code & building user-centric products. Tech visionary & digital marketer.