Teach you a trick to permanently solve the problem of MySQL inserting Chinese characters

Teach you a trick to permanently solve the problem of MySQL inserting Chinese characters

Preface

Problem description:

Incorrect string value:'\xD5\xC5\xC8\xFD' for column 'name' at row 1;

This article uses the modification of configuration files, which can be done in a few minutes. Please back up before modification~~

Some friends will get an error when inserting Chinese into MySQL, so we need to specify the character set.

Use a command to view the character set of the current data~ (Latin when not modified)

show variables like '%character%';

We can have temporary solutions and permanent solutions. Here we only talk about permanent solutions:

To support Chinese, change to utf-8

1. First find the mysql configuration file my.ini

This file contains many mysql configurations, both client and server.

first step:

In this directory:

Right click properties:

Copy the target content to Notepad:

“C:\Program Files\MySQL\MySQL Server 5.7\bin\mysql.exe” “–defaults-file=C:\Program Files\MySQL\MySQL Server 5.7\my.ini” “-uroot” “-p” “–default-character-set=utf8”

This section looks for the target file: C:\Program Files\MySQL\MySQL Server 5.7\my.ini

If this file does not exist, you can check whether it is hidden:

Then find this file

Step 2: Modify this my.ini

Note that when modifying my.ini, you must back up and copy and paste it (this is a good working habit)

Find this location: Change to utf8 (not utf-8)

Change 2:

In mysqld here

Remove the comment and the value will become utf8.

After the modification is completed, save and close it! Finally, you can use the first command to view the same as above picture~~

Summarize

This is the end of this article about permanently solving the problem of Chinese text insertion failure in MySQL. For more relevant content on solving the problem of Chinese text insertion failure in MySQL, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Solution to the problem that Chinese characters are converted into full question marks when inserted into Mysql???
  • How to solve the problem of Chinese garbled characters when inserting table data into MySQL
  • Five ways to insert Chinese characters into MySQL without garbled characters
  • Solve the problem that MySQL cannot insert Chinese incorrect string value
  • mysql cannot insert Chinese characters
  • Mysql insert Chinese and Chinese query (modification + debugging)

<<:  List of commonly used escape codes for HTML greater than, less than, spaces, quotation marks, etc.

>>:  CSS achieves the effect of aligning multiple elements at both ends in a box

Recommend

Tomcat obtains the client domain name of Nginx reverse proxy

question After Nginx reverse proxy, the Tomcat ap...

Steps to set up and mount shared folders on Windows host and Docker container

Programs in Docker containers often need to acces...

How to implement parent-child component communication with Vue

Table of contents 1. Relationship between parent ...

Bootstrap 3.0 study notes buttons and drop-down menus

The previous article was a simple review of the B...

Summary of Linux command methods to view used commands

There are many commands used in the system, so ho...

MySQL uses init-connect to increase the implementation of access audit function

The mysql connection must first be initialized th...

Essential bonus items for optimizing and packaging the front end of Vue projects

Table of contents Preface 1. Routing lazy loading...

Practice of el-cascader cascade selector in elementui

Table of contents 1. Effect 2. Main code 1. Effec...

Detailed explanation of JS array methods

Table of contents 1. The original array will be m...

The HTML 5 draft did not become a formal standard

<br />Yesterday I saw at W3C that the new HT...

Master the CSS property display:flow-root declaration in one article

byzhangxinxu from https://www.zhangxinxu.com/word...

A small problem about null values ​​in MySQL

Today, when testing the null value, I found a sma...