Fixing Issues by Hacking the Database

One of the more common issues with WordPress upgrades is the widgets going crazy, sometimes outputting only a blank page on your blog. While this seems to be a lot less common these days, the upgrade instructions still state that you should disable all plugins and revert to the default theme. If you do, most likely you'll never get that blank page.

However, should you get a blank page, it is probably a widget issue. A possible solution is to clean out the widgets in the database; they are hiding in the wp_options table. Exactly what you need to do and what the various widgets are called depends on what plugins you have, so tread carefully. Most likely the data is named in a way that seems logical compared to the plugins you use, and with that in mind you should be able to find what you're looking for. It may sound a bit hazardous, but it is worth giving it a go should you encounter a blank screen on your blog after an upgrade.

Finally, you may want to mass edit your posts. Maybe you've got a new domain and want to change the source for all images you've used over the years, from image.jpg to, for example. There are plugins that will help you with this, so most of us should probably check them out first. If you're comfortable with the database, though, you can run a SQL query to search for all these elements and replace them with the new ones. It could be some thing like this:

UPDATE wp_posts SET post_content = REPLACE ( post_content,

'', '');

That would search the wp_posts table for any mention of and replace it with That in turn would fix all the image links in the example above. Nifty little SQL queries for batch editing can come in handy, but remember: there are no undos here and what's done is done, so make sure you've got backups before even considering doing these things.

Another issue you may want to resolve in the database is changing or resetting a password for a user. You can't actually retrieve the password from the database because it is encrypted and all you'll see is gibberish, but you can change it to something else. Just remember that the passwords needs the MD5 treatment, which can be done through PhpMyAdmin or just about any MySQL managing tool you may use. Basically, what you do is type the new password in plain text, and choose MD5 for that particular field. You'll end up with a new line of gibberish, which actually says what you typed in the first place. Again, if this sounds scary to you, don't do it without exploring other solutions first!

Was this article helpful?

0 0

Post a comment