[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:
- Dump the database with:
- Edit the dump file replacing the occurence "SET NAMES latin1" with "SET NAMES utf8"
- Restore the dump to database with:
- Voila! The å, ä and ö were looking just fine in my local copy of the db
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: