Changing the character set of a MySQL database can be done easily like this from the command line:

DB="dbname"; ( echo 'ALTER DATABASE `'"$DB"'` CHARACTER SET utf8 COLLATE utf8_general_ci;'; mysql "$DB" -e "SHOW TABLES" --batch --skip-column-names | xargs -I{} echo 'ALTER TABLE `'{}'` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;' ) | mysql "$DB"

You would of course change "dbname" above to the name of your database. 

 

Credit goes to Jasny - Arnold Daniels from this Stackoverflow thread for this one line method of changing the charset of a MySQL database to utf8.

Share

Comments (0)

No comments found!

Write new comment