Mysql through my. cnf to modify the default character set for UTF-8 method and precautions, my. cnfutf-8
Option Configuration
Configuration File Path: /full/path/mysql/bin/my.cnf
(Default value:/etc/my.cnf
)
[client]default-character-set=utf8[mysql]default-character-set=utf8[mysqld]init_connect='SET collation_connection = utf8_unicode_ci'init_connect='SET NAMES utf8'character-set-server=utf8collation-server=utf8_unicode_ciskip-character-set-client-handshake
* Note:
Use default-character-set settings in mysqld. mysql startup reports an error and cannot start.
Description
For the utf8 character set, we use the following default options in China:utf8_general_ci
Insteadutf8_unicode_ci
,
The difference lies in character comparison.
See the example above in mysql:
For general, period = s is true.
However, for unicode, bytes = ss is true,
In fact, their differences are mainly in German and French. for Chinese, general is generally used because general is faster.
Unicode is more accurate than general if you have higher requirements for comparison between German and French (more accurate in comparison or sorting according to German and French Standards)
Look at this document: http://dev.mysql.com/doc/refman/5.7/en/charset-unicode-sets.html
In addition, utf8_bin_ci is also commonly used. unicode and general are not case sensitive during character comparison. Therefore, if Case sensitivity is required, bin is used.
Summary
The above is all about this article. I hope to help you in your study or work. If you have any questions, please leave a message.