HOWTO: Convert mysql data to UTF-8 quickly post
I\'ve been revamping my Bolivian soccer
blog, which I finally updated and made
live tonight. In doing so, I needed to convert the data from ISO-8859-1
(back when I didn\'t know better about how to setup a database) to
UTF-8. I was fearing the process would be complicated and tedious,
involving some script to read the data and use PHP\'s mbstring or iconv
extensions to do the work. Thanks to a post on a Mysql message board (I
wish I\'d saved the link, I\'d give you full credit), it turned out to
be a drop dead simple, or is it quick-and-dirty, 3 step process at the
command line using the iconv tool.
$ mysqldump --opt --quote-names my_database > my_database.sql
$ iconv -f ISO_8859-1 -t UTF-8 my_database.sql > my_database-utf-8.sql
$ mysql my_database < my_database-utf-8.sql
Categories: Uncategorized