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

VMware virtual machine to establish HTTP service steps analysis

1. Use xshell to connect to the virtual machine, ...

Methods and techniques for quickly displaying web page images

1. Use .gifs rather than .jpgs. GIFs are smaller ...

foreman ubuntu16 quick installation

Quickstart Guide The Foreman installer is a colle...

What are the advantages of using B+ tree index in MySQL?

Before understanding this problem, let's firs...

Detailed explanation of common commands in Docker repository

Log in docker login Complete the registration and...

Detailed explanation of MySQL custom functions and stored procedures

Preface This article mainly introduces the releva...

Things to note when writing self-closing XHTML tags

The img tag in XHTML should be written like this:...

Solve the mysql user deletion bug

When the author was using MySQL to add a user, he...

Detailed explanation of the syntax and process of executing MySQL transactions

Abstract: MySQL provides a variety of storage eng...

Three ways to configure JNDI data source in Tomcat

In my past work, the development server was gener...

Solution to input cursor misalignment in Chrome, Firefox, and IE

Detailed explanation of the misplacement of the in...

MySQL GTID comprehensive summary

Table of contents 01 Introduction to GTID 02 How ...