Home > Database > Mysql Tutorial > What should I do if the Chinese garbled data inserted into the table data in mysql should be solved?

What should I do if the Chinese garbled data inserted into the table data in mysql should be solved?

coldplay.xixi
Release: 2023-01-04 09:36:09
Original
19644 people have browsed it

Solution to Chinese garbled Chinese characters when inserting table data into mysql: 1. Check whether the default encoding method of the local mysql installation file directory is utf8; 2. Start the mysql service and enter the relevant commands to encode the character set of the default database table. Change to utf8; 3. Restart the service.

What should I do if the Chinese garbled data inserted into the table data in mysql should be solved?

The operating environment of this tutorial: Windows 7 system, mysql version 8.0.22, DELL G3 computer.

Solution to Chinese garbled table data inserted into mysql:

1. Check the my.ini configuration file in the local mysql installation file directory, the default settings of the server and client Is the encoding method utf8

[mysqld]
# 服务端使用的字符集默认为UTF8
character-set-server=utf8
 
[client]
# 设置mysql客户端连接服务端时默认使用的端口
default-character-set=utf8
Copy after login

2. After the previous step is correct, open the command line and enter: net start mysql to start the mysql service; after

displays "The service has been started successfully", enter the command "mysql", use the database;

What should I do if the Chinese garbled data inserted into the table data in mysql should be solved?

## Check the character set encoding format of the database table: enter the command "show create table test.xtt_test_copy; ";

What should I do if the Chinese garbled data inserted into the table data in mysql should be solved?

As shown in the figure above, it is found that the default is "latin1" and not "utf8". You need to continue to modify it manually. Enter the command "ALTER TABLE test.xtt_test_copy CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;" and continue to enter. Command "show create table test.xtt_test_copy;" to view the character set encoding of the default database table changed to "utf8";

What should I do if the Chinese garbled data inserted into the table data in mysql should be solved?

To view the character set encoding format of the database: enter the command " show creat database test; ”;

What should I do if the Chinese garbled data inserted into the table data in mysql should be solved?

As shown in the figure above, it is found that the default is "latin1" and not "utf8". You need to continue to modify it manually. Enter the command "ALTER DATABASE" test DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;", continue to enter the command "SHOW CREATE database test;" and check that the character set encoding of the default database table has been changed to "utf8";

What should I do if the Chinese garbled data inserted into the table data in mysql should be solved?

3. Finally, just restart the service~

mysql> net stop mysql;
mysql> net start mysql;
Copy after login

Related free learning recommendations: mysql video tutorial

The above is the detailed content of What should I do if the Chinese garbled data inserted into the table data in mysql should be solved?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template