##/etc/my.cnf:
# [mysql]
# default-character-set=utf8
# [mysqld]
# character-set-server=utf8
# collation-server=utf8_general_ci
# [client]
# default-character-set=utf8
/etc/init.d/mysqld stop
/etc/init.d/mysqld start
# dump db
mysqldump -u dbuser -pdbpass --opt --skip-set-charset --default-character-set= latin1 --skip-extended-insert databasename > database.table.sql
# replace charset
perl -i -pe 's/DEFAULT CHARSET=latin1/DEFAULT CHARSET=utf8/' database.table.sql
# import db
cat database.table.sql | mysql -u dbuser -pdbpass databasename
Set MySQL to use UTF-8 and convert database
最新推荐文章于 2023-02-11 10:37:58 发布