6

Due to some important hardware failure, the wp_options table of one of my WP sites became corrupted, but everything else is okay (WP files and other tables). Obviously the site does not work because of this, and I had no backups.

What would be the best way to repair this? How can I create a fresh wp_options table for my WP version?

2 Answers 2

7

Uh oh, that's an important table. You might have lost a bunch of options, but you can still repair the database. WordPress allows a repair mode, which you can repair the database.

Open the wp-config.php file using FTP, and add this line before the ABSPATH:

define( 'WP_ALLOW_REPAIR', true );

now head over to :

http://yourdomain.com/wp-admin/maint/repair.php

Follow the steps to repair your broken database.

4
  • The tool is reporting "Failed to repair the wp_options table. Error: Table 'site.wp_options' doesn't exist". I dropped the table because selecting from it would make MariaDB crash, even with innodb_force_recovery set to 6. So should I install a new WordPress having the same version and copy its fresh wp_options table to my site's database?
    – eepp
    Commented Sep 24, 2018 at 21:49
  • Yes you could do that. Have you also tried creating an empty wp_options tab manually using phpmyadmin, and then running the repair mode?
    – Johansson
    Commented Sep 24, 2018 at 22:12
  • Unfortunately it does not rebuild WP_OPTIONS. Commented Oct 24, 2019 at 6:39
  • @AntonioPetricca I assume that table is built while installing WordPress. Many of its options are added by plugins, themes, etc.
    – Johansson
    Commented Oct 24, 2019 at 7:52
1

Your last suggestion (question?) is the right way to go, especially since you've already dropped that table.

Install a fresh version of WP into a new database (same version as your existing site), the export that table only from the new install and import it into your existing database.

Then BE SURE to set the two options that are critical, which is the blog URL and home URL, while you're still in phpMyAdmin, all other options can be set via the /wp-admin/ back-end when you can access it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.