Home > Database > Mysql Tutorial > body text

Detailed explanation of Mac environment mysql5.7.21 utf8 encoding problem

小云云
Release: 2018-03-14 09:49:01
Original
1717 people have browsed it

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
Copy after login

3. Copy my.cnf to /private/etc/


cp /usr/local/mysql/support-files/my.cnf /private/etc/my.cnf
Copy after login

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%';
Copy after login
You can find that the encoding values ​​​​are changed to utf8.

At this point, re-create the database and table, and import the data to display Chinese normally.

Related recommendations:

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!