A view character set
mysql> show variables like 'character%';
+--------------------------+-----------------------------------------------------------+
| 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
Second, in order to avoid garbled, change the default character set is UTF-8 Full
/usr/local/mysql-5.7.19-macos10.12-x86_64/support-files
Most online article said .cnf a copy of the file in this directory under / etc my.cnf to make changes to the file, but in 5.7.19 version of this catalog has not .cnf file (version 5.7.17 has .cnf file), the official website gives instructions to remove this file. Then we manually in the / etc my.cnf file is created.
Third, create a my.cnf file in / etc, as follows (can not be saved, then use the command sudo vim)
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
[mysqld]
collation-server=utf8_unicode_ci
init-connect='SET NAMES utf8'
character-set-server=utf8
Fourth, after the restart mysql view the character set has been modified, if you want to modify the Chinese, the corresponding content can be changed to gb2312.
mysql> show variables like 'character%';
+--------------------------+-----------------------------------------------------------+
| Variable_name | Value |
+--------------------------+-----------------------------------------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
Fifth, after some friends might create my.cnf in / etc still not successful, it would create a my.cnf file in the / private / etc.