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 - 4:51pm

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

Thanks for the module - worked like a charm!

Salman Al-Rahma (not verified) | drupal 5 | Tue, 2007/05/15 - 2: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> <blockquote> <sup> <sub> <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

About

Ayman Hourieh

Computer Science graduate, Open Source enthusiast and Software engineer (Site reliability) at Google.

I'm 26 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

Feeds

RSS Feed Twitter

Books

Django 1.0 Website Development

Django 1.0 Website Development
Build powerful web applications, quickly and cleanly, with the Django application framework.

The second edition of my Django book. Published by Packt Publishing in March 2009.

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.