1

In a moment of sheer stupidity, I deleted the wordpress database for a site of mine. Fortunately, it was a young site with only a few pages.

Now, I understand that everything that was stored in that database is gone - including posts etc. I was able to recover most of them using Google Webcache.

My question is, rather than re-installing Wordpress on my server, can I recreate just the database?

If not, what would be the easiest way to restore Wordpress to working order without losing all the little changes I had made which included plugins, modifications to the theme I was using etc? I feel this should be possible considering I still have all the files on my filesystem, just the database is missing.

2
  • 3
    The database saves all the options you had set, so those are gone, but you can use the plugins and theme files you already have. Just create a new database and edit the existing wp-config.php file to use it. You might also talk to your host and see if they have a full backup they could restore for you.
    – mrwweb
    Commented Apr 23, 2012 at 4:26
  • Hmm...it might be worth a shot to talk to them. Thanks.
    – Ayush
    Commented Apr 23, 2012 at 4:38

2 Answers 2

1

If the database is gone, your posts, pages, widget settings and other such data is gone. There's no way to "recreate" the old database. You need to reinstall WP and start with a site with no content.

If you have a copy of the theme and actual code modifications, that's good. There is a difference between what can be called the "static" content and the "dynamic" content. Dynamic is the actual page/post text content and is in the database. Static content are the theme and plugin files, uploaded images and other such files.

Ask your web host if they have a backup. And once you're up again, install a backup plugin and keep daily database and theme backups.

1
  • Yeah, learnt my lesson about backups the hard way. Any recommendations. My host is GoDaddy. I'll give them a call and see.
    – Ayush
    Commented Apr 23, 2012 at 4:42
1

SSH in and use the wp-cli command:

wp db reset

After that you will have to go through the WordPress installation process again. The installation won't delete any plugin or theme files (tested in 2023).

If you don't have wp-cli in your hosting environment, you can use the following commands instead:

curl -o wp-cli.phar https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
php wp-cli.phar db reset

Warning: All content and settings are stored in the database. You will lose just about everything by doing this. This can be desirable if you are developing a plugin or theme and want to test things out on a fresh DB.

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.