Howto backup and restore MySQL database with character set intact

If you want to preserve characters like ñ, ó, ç, etc. when migrating a MySQL database use mysqldump to export the database with this options:

 mysqldump -u root -p --default-character-set latin1 --skip-character-set <dbname> > mydump.mysql

create the target database with:

mysqladmin -u root -p create <dbname> --default-character-set latin1 --collate latin1_swedish_ci

then restore:

mysql -u root -p --default-character-set latin1 <dbname> < mydump.mysql