Most of the time you needn’t worry about the database; WordPress will do that for you. There are database changes between versions sometimes, but program updates will take care of everything, and other than keeping a backup of your content the database can be leftto live its own life.
That being said, if things go wrong you may need to do some edits in the database to fix them. Common issues are password resets, weird URLs as a result of a failed move, domain name changes, and not forgetting the dreaded widget issue. Before moving on, you should remember that making alterations in the database is serious stuff. There are no undos here; what is deleted is deleted for good. Even if you know what you’re doing you should always make a fresh backup before altering anything at all. Should you not know your way around a MySQL database and PhpMyAdmin, then don’t mess with it until you do. You will break things.
Finding your way in the WordPress database is pretty easy. It consists of 10 tables, which in turn are full of content. Just browsing the database should answer most of your questions, and any edits can be made right then and there if you know what you’re after. Naturally, there is a full database description in the documentation (codex.wordpress.org/Database_Description) and you should consult that whenever you need to find something. The 10 main tables are:
All these tables are important, of course, but if you need to fix or change something directly in the database, chances are that it is in wp_options (for weblog settings, like URLs and such), wp_posts (for mass editing of your weblog posts), or wp_users (for password resets and such).
One of the more common issues with WordPress upgrades is the widgets going crazy, sometimes outputting only a blank page on your weblog. 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 weblog after an upgrade.
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!
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 olddomain.com/wp-content/ image.jpg to newdomain.com/wp-content/image.jpg, 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, 'olddomain.com/wp-content/', 'newdomain.com/wp-content/');
That would search the wp_posts table for any mention of olddomain.com/wp-content/ and replace it with newdomain.com/wp-content/. 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.
Our website is not responsible for the information contained by this article. Articleinput.com is a free articles resource thus practically any visitor can submit an article. However if you notice any copyrighted material, please contact us and we will remove the article(s) in discussion right away.
Note: This article was sent to us by: Orlando F. at 05132010
1. Wordpress Plugins and Functions PHP
© 2009 ArticleInput.com.