This article mainly introduces to you the Mac environment mysql5.7.21 utf8 encoding problems and solutions. I hope it can help you.
1. Goal: Change the value of mysql's character_set_server from latin1 to utf8
Temporarily: SET character_set_server=utf8 is enough, one-time.
Permanent: The configuration file needs to be changed, see step 2.
2. There is no configuration file in the support-files of mysql 5.7.21.
Create new my.cnf. You can create a text file and directly change the extension to cnf. 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 stand-in for /private/etc, and can be copied to both.
4. Restart the mysql server and enter mysql
##
mysql>show variables like '%char%';
The function of detecting whether a string is utf8 encoded under php
Base64, UTF8 encoding and decoding in javascript Detailed explanation
String array php code to detect whether the string is utf8 encoded
The above is the detailed content of Detailed explanation of Mac environment mysql5.7.21 utf8 encoding problem. For more information, please follow other related articles on the PHP Chinese website!