mysql5.7.21 utf8 encoding problem and solution in Mac environment

mysql5.7.21 utf8 encoding problem and solution in Mac environment

1. Goal: Change the value of character_set_server of mysql from latin1 to utf8

Temporary: SET character_set_server=utf8, one-time.

Permanent: You need to change the configuration file, see step 2.

2. There is no configuration file in the support-files of mysql 5.7.21.

Create a new my.cnf. You can create a text file and directly change the extension to cnf. It is best 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: /etc is actually a stand-in for /private/etc and can be copied to either.

4. Restart the mysql server and enter mysql

mysql>show variables like '%char%';

You can find that the encoding values ​​are all changed to utf8.

At this time, rebuild the database and table, and import the data to display Chinese normally.

Summarize

The above is the mysql5.7.21 utf8 encoding problem and solution in Mac environment introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!

You may also be interested in:
  • How to configure Python Anaconda environment in PyCharm on Mac
  • How to configure Anaconda environment in PyCharm on Mac
  • Detailed installation of PHP environment and extensions on Mac
  • How to use VirtualBox to build a local virtual machine environment on Mac
  • How to build a python environment on macOS
  • Detailed steps to quickly build a PHP development environment on Mac
  • Correct installation and configuration of Go environment and VS Code on Mac
  • How to configure gradle environment in Mac and use android studio to package jar package and arr package
  • How to modify the environment variable path in Mac

<<:  How to explain TypeScript generics in a simple way

>>:  Steps for Vue3 to use mitt for component communication

Recommend

CSS3 flip card number sample code

I received a task from the company today, and the...

In-depth explanation of MySQL common index and unique index

Scenario 1. Maintain a citizen system with a fiel...

Implementation of WeChat applet message push in Nodejs

Select or create a subscription message template ...

A simple way to implement all functions of shopping cart in Vue

The main functions are as follows: Add product in...

CSS Transition expands and collapses elements by changing the Height

A common development need is that we want to coll...

Axios project with 77.9K GitHub repository: What are the things worth learning?

Table of contents Preface 1. Introduction to Axio...

Summary of practical experience of HTML knowledge points

1. The table tag is table, tr is row, td is cell, ...

Learn about TypeScript data types in one article

Table of contents Basic Types any type Arrays Tup...

How to use display:olck/none to create a menu bar

The effect of completing a menu bar through displ...

Several ways to manually implement HMR in webpack

Table of contents 1. Introduction 2. GitHub 3. Ba...

TypeScript enumeration basics and examples

Table of contents Preface What are enums in TypeS...

Deleting files with spaces in Linux (not directories)

In our daily work, we often come into contact wit...

Learn Node.js from scratch

Table of contents url module 1.parse method 2. fo...

Detailed introduction to MySQL database index

Table of contents Mind Map Simple understanding E...