Converting MySQL Data from Latin1 to GB2312 (or other encoding)

October 28th, 2008

I was moving our GoSeeUS.cn website from one hosting to another and need to transfer the database over as well.

Database export and import both went smoothly but the Chinese characters were all scrambled on the new hosting server. After some research I found that the old hosting used MySql 5.0 and had the encoding set to Latin1 while the new hosting was still on MySql 4.0 and the encoding was GB2312.

My research and debugging went late into night… I tried “set names” but it didn’t work for MySql 4.0. I also tried to specify charset … none worked. Three hours down the drain but no progress.

Second day in the morning, inspired by a tip from a colleage in China, I decided to try a different program — rather than battling with phpMyAdmin provided by the hosting company.

I downloaded SQLWave from http://www.nerocode.com/. Installation was a breeze. While familiarizing myself with different menu options, I saw “transfer database”. So I gave it a try. There was an option for charset on one of the import screen, and I chose “gb2312”. In 5 minutes, the entire database was transferred over, USING THE CORRECT CHARSET! The website http://www.GoSeeUS.cn is now living happily on the new server in Beijing.

Big thanks to Nerocode for the beautiful software SQLWave!

Please add your comment