mysqldump -u root -p –opt –default-character-set=latin1 –insert-ignore –skip-set-charset DBNAME > DBNAME.sql
Then using sed I changed all occurrences of the word latin1 to utf8:
iconv -f ISO-8859-1 -t UTF-8 DBNAME.sql > DBNAME_new.sql
sed -e ‘s/latin1/utf8/g’ -i ./DBNAME.sql
From here I then created the new database and then imported the dumpfile.
mysql -p -e “create database DBNAME”
mysql -p –default-character-set=utf8 DBNAME < DBNAME.sql