Geekery

Replace Data in MYSQL Table

If you change domain with your blog, but decided to stick to the same database , probably you will have to update several URLs in your entries.

I’m a lazy person and everything which can be done automatically, will be be automated. Replacing links or words in your WordPress database table is a really simple act. Of course, you should first backup your database .

Open your CPanel or Plesk backend and move to the Database —> phpMyAdmin area. Select your database here and move to wp_posts

The syntax to replace strings/data/words/whatevah in your database is simple:

update tablename set field = replace(field,'search_for_this','replace_with_this');

In my case I had to change the URL from serialrecidivism.com; to ifranky.com/amifamousnow, the string looked as this:

update wp_posts set post_content = replace(post_content,'http://serialrecidivism.com','http://ifranky.com/amifamousnow');

go, phpMyAdmin will now tell you how many strings have been changed and you can admire how all your links are supposed to work again, intra-entry.

Congratulations, after some Googling, you now have become a MYSQL authority!

Standard
Geekery

Backup Your Database With An Automated Cron Job

With every update for WordPress everyone who actually bothers to read the readme or howto sees the warning/instruction

Step 1: Backup Database Tables and Files including .htaccess

Use phpMyAdmin or other appropriate tools provided by your webhost, to backup the database used by WordPress.

Luckily the WordPress codex points at phpMyAdmin for the database backup, because the WordPress export feature is officially useless as a backup tool.
There are several backup plugins for WP, but most don’t serve the optimal purpose.

As blogger you should not only backup your database when you upgrade but you should regularly back your data up. But honestly, who visits regularly the options to backup the database.
I known many website owners, or bloggers, who’d love to know how to regularly backup the database in order to avoid losing all their posts every time they screw up their Cpanel config.
Luckily the mysql backup process can easily be automated with a cron job.Since many bloggers have cPanel, here is a short howto automate your mysql database backup with a cron job in cPanel. Continue reading

Standard