Get the App
SLTechnology News&Howtos  ›  Development  › 

How to solve the problem of Incorrect string value in Mysql

Shulou Source: shulou.com Published: 2022-06-03 10:29:54 11月15日 Update

How to solve the problem of Incorrect string value in Mysql, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.

Many friends will report the following error when inserting Chinese characters using mysql:

This is because we do not specify a character set, the storage of characters in the computer is represented by a two-tier system, and similarly, Chinese characters need to be stored in binary, so we need to specify a table (representation rules: what Chinese characters correspond to what binary). Generally speaking, utf8 is commonly used. Of course, you can also specify utf8mb4, which can be used to represent more special symbols, such as facial expressions, but it is sufficient to use utf8 in our daily use. Let's take specifying the character set of utf8 as an example:

First find the Mysql program in the start menu:

Just right-click either of these two, and then click more-Open File location:

Also right-click any one of them, and then click Properties to find the path corresponding to my.ini in the target path:

Then right-click my.ini to open it in notepad

Write utf8 after the equal sign under [mysql]

Similarly, add utf8 to the right of the equal sign under [mysqld] (note that there can be no spaces on both sides)

Pay special attention!

1. Delete the pound sign in front of these two statements after adding utf8 to prevent it from being mistaken for comments by the system!

two。 If you are afraid to correct your mistakes before you modify them, you can make a backup copy of my.ini (copy and paste) in advance.

After the modification, we can restart the computer, so that there will be no errors when adding Chinese characters in the future. (note here, before modification, we will still report errors when inserting Chinese characters into the original database. We should create a new database)

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Tags: Chinese characters characters more binary data database equal sign path face will report store help Zhongguan clear special two middle use location content right Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Microsoft vpn Huawei Apple