random thoughts to oil the mind

Tag: Unicode

Playing with the WordPress Database

After initially solving my database character encoding problems by ignoring the specific strings in the wp-config.php file, I was finally forced to alter the characters in the database during a recent reshuffle. Whilst there are two automated solutions available via plugin, namely g30rg3x‘s UTF-8 Database Converter and the Modified UTF8 Sanitize Plugin, sadly neither worked in my particular instance, and indeed the former is no longer supported for current versions of WordPress, though reports on the WordPress support forum suggest there should be no issues.

Fortunately, an excellent guide was available on Alex King’s blog. For more information and follow-up comments, you should definitely read the full post, but here’s a summary of the method that worked for me.

WordPress 2.2 Database Character Sets

For those upgrading their WordPress powered blogs to 2.2, just a word of warning regarding the new character encoding options available in the wp-config.php file.

The standard file should have a section which reads:

// ** MySQL settings ** //
define('DB_NAME', dbname// The name of the database
define('DB_USER', 'dbuser'); // Your MySQL username
define('DB_PASSWORD', 'dbpassword'); // ...and password
define('DB_HOST', 'localhost');
define('WP_HOME', 'http://www.yourblog.com/');
define('WP_SITEURL', 'http://www.yourblog.com/');
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', 'utf8');

Note the new options added at the bottom regarding the codepage used in the blog’s database. If these are set incorrectly they may make your blog unreadable, else prevent special characters from appearing correctly. I personally found that commenting these two lines out left the blog functioning as before, but for people wishing to change the codepage of their database, WordPress has a rough guide available, originally written for the beta testers.

Powered by WordPress & Theme by Anders Norén