Last active
November 30, 2019 21:36
-
-
Save tanchao90/d758912446b122d70a0ce64d0ed98b37 to your computer and use it in GitHub Desktop.
mysql-5.7.19 customized config file
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
# The MySQL database server configuration file. | |
# | |
# You can copy this to one of: | |
# - "/etc/mysql/my.cnf" to set global options, | |
# - "~/.my.cnf" to set user-specific options. | |
# | |
# One can use all long options that the program supports. | |
# Run program with --help to get a list of available options and with | |
# --print-defaults to see which it would actually understand and use. | |
# | |
# For explanations see | |
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html | |
# | |
# * IMPORTANT: Additional settings that can override those from this file! | |
# The files must end with '.cnf', otherwise they'll be ignored. | |
# | |
!includedir /etc/mysql/conf.d/ | |
!includedir /etc/mysql/mysql.conf.d/ | |
# customized config | |
[client] | |
default-character-set = utf8mb4 | |
[mysql] | |
default-character-set = utf8mb4 | |
[mysqld] | |
character-set-server = utf8mb4 | |
collation-server = utf8mb4_unicode_ci | |
init_connect='SET NAMES utf8mb4' | |
init_connect='SET collation_connection = utf8mb4_unicode_ci' | |
character-set-client-handshake = FALSE | |
# character-set-client-handshake = FALSE | |
# it will always use default encoding even if you will make mistake on application layer | |
# skip-character-set-client-handshake | |
# To ignore client information and use the default server character set |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Before (Use default config)
mysql> SHOW VARIABLES LIKE 'char%'; SHOW VARIABLES LIKE 'collation%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)
+----------------------+-------------------+
| Variable_name | Value |
+----------------------+-------------------+
| collation_connection | utf8_general_ci |
| collation_database | latin1_swedish_ci |
| collation_server | latin1_swedish_ci |
+----------------------+-------------------+
3 rows in set (0.01 sec)
After add customized config
mysql> SHOW VARIABLES LIKE 'char%'; SHOW VARIABLES LIKE 'collation%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8mb4 |
| character_set_connection | utf8mb4 |
| character_set_database | utf8mb4 |
| character_set_filesystem | binary |
| character_set_results | utf8mb4 |
| character_set_server | utf8mb4 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.01 sec)
+----------------------+--------------------+
| Variable_name | Value |
+----------------------+--------------------+
| collation_connection | utf8mb4_unicode_ci |
| collation_database | utf8mb4_unicode_ci |
| collation_server | utf8mb4_unicode_ci |
+----------------------+--------------------+
3 rows in set (0.00 sec)
character_set_system is always utf8.