Change MySQL default character set to UTF-8

22-01-2015

To set the default to UTF-8, you want to add the following to my.cnf or my.ini for Windows
[mysqld]
collation-server = utf8_general_ci
character-set-server = utf8

If you want to change the character set for an existing DB, you can use following code:
ALTER DATABASE databasename CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE tablename CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;

© 2019 All rights reserved. Codesenior.COM