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?

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.

  • 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 Sep 24 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? – Jack Johansson Sep 24 at 22:12

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 acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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