linux.code.hacks.gamedev

// So far, so little

Home Archive About Projects
8 March 2014

[SOLVED] mysqldump breaking character encoding on Swedish characters...

by Linus Probert

So... I was up for 4 hours too long last night fiddling with the stupid backups of a webshop that I wrote, launched and maintain for my wifes shop (http://www.houseofme.se/webshop).

As I was getting a fresh backup for some local development I noticed that all the å, ä and ö characters where distorted in my copy of the database but they weren't in the production environment. I fiddled with it alot and tore my hair for hours resulting in a very late night with no solution.

The next day I solved the whole thing with some hands on editing in less then an hour.

The cause: Production environment had latin1 character encoding for all the tables and columns in my database but was running utf8 in the console environment. This caused a problem that I have yet to understand. In short, the dump file was utf8 but was being read as latin1 even though the dump was actually utf8.

The solution:

I hope this helps someone as much as it relieved me when I found the solution. Because I was really pissed and really nervous when I relaized the issue since it might have meant that all the backups of the production environment were more or less useless.

I'm not a big writer so I'm going to end here. Good luck to anyone else who has this problem.

//Liq

tags: