0

mysql changing to utf8 and converting DB to utf8

by default mysql is installed as latin1 and sometimes it causes problems when your data is not always latin1.

Follow the steps to change mysql to utf and also convert existing databases to UTF8

#1 backup your databases and convert it to UTF8
mysqldump -uusername -ppassword -c -e --default-character-set=utf8 --single-transaction --skip-set-charset --add-drop-database -B dbname -r dbname.utf8.dump.sql

do this for each of your databases.

#2 shutdown mysql
service mysqld stop

#3 edit /etc/my.cnf

ADD to [mysqld] section
#
init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake

also

[client]
default-character-set=utf8

#4 restart mysqld
service mysqld start

#5 import your databases
mysql -u user -p < dbname.utf8.dump.sql

jlim0930

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.