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.
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
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;
## Check the character set encoding format of the database table: enter the command "show create table test.xtt_test_copy; ";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"; To view the character set encoding format of the database: enter the command " show creat database test; ”;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"; 3. Finally, just restart the service~mysql> net stop mysql; mysql> net start mysql;
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!