MySQL 4.0 to 4.1 Encoding Problem And Solution

Here is a solution for a problem I read about many times in the Drupal forums, but couldn't find any definite answer to: When upgrading or moving a database dump from MySQL 4.0 to 4.1, Unicode data stored by Drupal becomes gibberish. The attached module iterates over all tables in Drupal's database, and converts text columns to UTF-8. The bulk of work is already in Drupal's code (_system_update_utf8), the module simply makes use of it.

To use the module, install and enable it, then navigate to update.php, and select update 1 for the module, then initiate the update process. You may disable the module when done.

If you can't log in to your site after the upgrade and as a result can't enable the module (happened to me), then run the following MySQL query through MySQL's command-line client or an interface such as phpMyAdmin:

INSERT INTO system
  VALUES('modules/utf8upgrade/utf8upgrade.module',
  'utf8upgrade', 'module', '', 1, 0, 0, 0, 0);

A couple of warnings: if your database contains tables that belong to a web application other than Drupal, the module may have side effects on this application as it iterates over all tables. You may need to modify the iteration logic and limit it to Drupal tables.

if you want to use the module, please backup your database first. Although it worked for me, I can't guarantee that it will work for everyone. I do appreciate feedback, however.

AttachmentSize
utf8upgrade.tar.gz1.05 KB
Tags:
Submitted by Ayman on Tue, 2006/08/29 - 5:51pm.

Brian Delicata (not verified) | Thanks for the module - | Thu, 2006/10/12 - 5:26am

Thanks for the module - worked like a charm!

Salman Al-Rahma (not verified) | drupal 5 | Tue, 2007/05/15 - 3:22pm

Salam,

First of all, where are you man... it is been a while since you posted anything... I hope every thing is alright with you.

Second, I didn't have this problem until I moved my now drupal 5.1 site using MySQL 4.0.x to a new host which uses MySQL 5.x

Can you module work with Drupal 5.x?

Thanks

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <strike> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote> <sup> <sub> <h1> <h2> <h3> <b> <i> <u>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.

About

Ayman Hourieh

I'm a Computer Science graduate, an Open Source enthusiast, and a Googler.

I'm 24 years old, and live in Dublin, Ireland.

This is my personal blog. The views expressed on these pages are mine alone and not those of my employer.

More

Books

Learning Website Development with Django

Learning Website Development with Django
A beginner's tutorial to building web applications, quickly and cleanly, with the Django application framework.

My first book. Published by Packt Publishing in April 2008.

Icons

Get Firefox!
Drupal.org
Linux
Gentoo
Creative Commons License