English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Modify MySQL Default Character Set to UTF via my.cnf-8Methods and Notes

Option configuration

Configuration file path: /full/path/mysql/bin/my.cnf (default for/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=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake

*Note:

Use default in mysqld-character-set setting, mysql will report an error and cannot start when it starts up.

Description

About utf8Character set, the default choice in our country is: utf8_general_ci instead of utf8_unicode_ci,

The difference lies in character comparison.

Please see the example on MySQL above:

For general, ß = s is true.

For unicode, ß = ss is true only.

In fact, the difference between them is mainly in German and French. Therefore, for us Chinese, general is usually used because it is faster.

If you have higher requirements for the comparison of German and French, use unicode, which is more accurate than general (more accurate in comparison or sorting according to the standards of German and French).

Take a look at this document:http://dev.mysql.com/doc/refman/5.7/en/charset-unicode-sets.html

In addition, there is also utf8_bin_ci is also commonly used. In character comparison, unicode and general are not case-sensitive. Therefore, if case sensitivity is required, use bin.

Summary

That's all for this article. I hope it can bring some help to everyone's learning or work. If you have any questions, you can leave a message for communication.

Declaration: The content of this article is from the Internet, and the copyright belongs to the original author. The content is contributed and uploaded by Internet users spontaneously. This website does not own the copyright, has not been manually edited, and does not assume any relevant legal liability. If you find any content suspected of copyright infringement, please send an email to notice#w.3Please send an email to codebox.com (replace # with @ when sending an email) to report violations, and provide relevant evidence. Once verified, this site will immediately delete the infringing content.

You May Also Like