How to set default character set as UTF8 when importing a mysql database?

Normally, when importing a mysql database default character set will be UTF8. If not,
we can set it manually with the below methods….

1. mysql -u <username> -p –default_character_set ‘utf8′ databasename < database.sql(exported database).

2. if you are using a compressed file, then use…
1. If bzip2:
bzip2 -cd <database.bz2> | mysql –host=localhost –user=<username> -p<password> –default_character_set ‘utf8′ <database name>

This can be done easily by using phpmyadmin.When importing a database just select UTF8 from the below select box named ‘character set of the file’.

Leave a Comment