Warning Code: 1366 penstring value: ‘\xE5\x9C\xA8’ for column ‘content’ at row 1
This is because we store Chinese, and our table does not support Chinese character set. We use show variables like ‘character%’. View mysql’s current encoding:
It can be seen that the character set of database and Server USES latin1, and latin1 does not support Chinese, which leads to the error of storing Chinese.
I tried two ways to avoid the Chinese storage error problem:
1: Set server and Database to UTF8 type
Use the following command to set input on the command line:
Show variables like ‘% char %’;
set character_set_server = utf8;
set character_set_database = utf8;
Use the command above. If not, show Create table. To see if the specific column has the wrong character set.
2: Set the default character set when building the table
When I build tables, I usually set the default character set to UTF8 in the SQL statement to avoid some problems:
sql='''create table analysis(city varchar(20),companySize varchar(20),education varchar(20))default charset=utf8'''
The default Charset = UTf8 is added at the end of the statement to set the default charset= UTf8, or at the end of the SQL statement if additional parameters need to be set.
★★★★★ ★★ warm tips:
This is a people encounter a problem, here said once: when using SQL statements, some of the words, letters is a class of special characters similar to python, import, etc., so if you want to use the key words, need to add the quotes ` to it, such as ` index `, the index is the key word, if used directly, will be an error. Therefore, I need to pay special attention to the fact that I always make mistakes when using it. I just can’t find the problem and think of other mistakes. Fortunately, I suddenly remember this problem mentioned by the database teacher accidentally.
Read More:
- The problem of Chinese garbled data in MySQL
- Perfectly solve the problem of NPM start error: cannot find module ‘XX’
- Perfectly solve the error loading media: file could not be played error
- Solve the problem of Chinese garbled code of actibpm plug-in in idea
- Solve the problem of using logback console to print log Chinese characters in IDEA as garbled characters
- Change the path in the user directory in Chinese Ubuntu to English
- Solve the error of Chinese file uploaded by springboot
- The use of Chinese characters in Qt and the solution to the “error C2001: newline in constant” problem
- Solution to the problem of Chinese garbled in gradle console in idea
- Solving the problem of saving object set by save() function in R language
- Solving the problem of Chinese garbled code in qtring
- How to Perfectly Uninstall ZoneAlarm Free Firewall
- How to Fix errors in Chinese input of latex
- Chinese garbled fonts in win10 English system
- After Oracle 11g is installed, SQL_ Plus.exe The problem of Chinese garbled in command window
- Solution of Chinese display garbled code in Git Bash
- Solving Chinese garbled code in Java compressed file
- Configuring OpenGL in Chinese version of VS2010 and problem solving
- Solve MySQL installation error: initializing database prompts an error when installing mysql
- Solve net start mysql, start MySQL service, prompt system error 5. Access denied.