Mysql5.7.21 utf8 encoding problem and solution in Mac environment, mysql5.7.21utf8
1. Goal: to change the character_set_server value of mysql from latin1 to utf8
Temporary: SET character_set_server = utf8.
Permanent: to change the configuration file, see step 2nd.
2. There is no configuration file in support-files of mysql 5.7.21.
Create my. cnf. You can directly change the extension to cnf after creating this file. It is better to open it with Xcode or subline. The content is as follows:
[Mysqld] character-set-server = utf8 [client] default-character-set = utf8 [mysql] default-character-set = utf8
3. Copy my. cnf to/private/etc/
Cp/usr/local/mysql/support-files/my. cnf/private/etc/my. cnf
Note: In fact,/etc is a replacement of/private/etc, which can be copied to both.
4. Restart the mysql server and enter mysql
Mysql> show variables like '% char % ';
We can find that the encoding values are changed to utf8.
Create a new database and then import the data to display Chinese characters.
Summary
The above section describes the Problem and Solution of utf8 encoding in mysql5.7.21 in the Mac environment. I hope it will help you. If you have any questions, please leave a message, the editor will reply to you in a timely manner. Thank you very much for your support for the help House website!