View Single Post
Old 06-22-2009, 10:36 AM   #16 (permalink)
sketchMedia
The Prestige
Advanced Programmer Top Contributor Good Samaritan 
 
sketchMedia's Avatar
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
sketchMedia is on a distinguished road
Default

you could try converting the contents of your DB to utf with iconv.

NOTE:
the text 'sketch@talkphp:~$' is my attempt at emulating the command line

Code:
sketch@talkphp:~$ mysqldump -u user -p databasename > databasename.sql
You may want to create a backup DB:
Code:
sketch@talkphp:~$ mysql -u username -p
mysql>create database databasename-backup;
mysql>exit
Bye
sketch@talkphp:~$ mysql -u username -p databasename-backup < databasename.sql
Now we can run the dump through iconv
Code:
sketch@talkphp:~$ iconv -f Latin1 -t utf8 databasename.sql > databasename-iconv.sql
Now create a new DB or reuse the old on and dump it back in (making sure that the tables and database are set to utf8):
Code:
sketch@talkphp:~$ mysql -u root -p databasename < databasename-iconv.sql
Sorry, i don't know how you would do this on redmond.

Alternitively you could try this fudge.
basically convert the column with the problem data in to a binary format then convert back the charset to utf8 again, this should force mysql to convert the data.
Code:
sketch@talkphp:~$ mysql -u root -p databasename
mysql>alter table tbl_name modify column col_name CHAR(255) CHARACTER SET binary;
mysql> alter table tbl_name modify column col_name CHAR(255) CHARACTER SET utf8;
obviously replace the 'CHAR(255)' with whatever the current data type is.

I haven't tested it, so you would be best advised to create a backup!
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
sketchMedia is offline  
Reply With Quote