Last active
June 2, 2017 12:11
-
-
Save jpzhu/0c5016c7825bdb8a69a8963a53d280fc to your computer and use it in GitHub Desktop.
mysql utf8 support
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. #数据库的uf8默认编码支持,建表的时候设置,如果开始没设置可以重置。 | |
mysqldump -uusername -ppassword -c -e --default-character-set=utf8 --single-transaction --skip-set-charset --add-drop-database -B dbname > dump.sql | |
cp dump.sql dump-fixed.sql | |
vim dump-fixed.sql | |
:%s/DEFAULT CHARACTER SET latin1/DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci/ | |
:%s/DEFAULT CHARSET=latin1/DEFAULT CHARSET=utf8/ | |
:wq | |
mysql -uusername -ppassword < dump-fixed.sql | |
ref:https://docs.moodle.org/23/en/Converting_your_MySQL_database_to_UTF8 | |
2. # 数据库连接时指定编码 | |
jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=utf8 | |
ref:http://www.cnblogs.com/surge/p/3581941.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment