Solve the problem of Chinese garbled characters in Mysql5.7 and Chinese garbled characters in mysql5.7
When using mysql5.7, you will find garbled characters appear after you write Chinese characters to the database through the web end. However, after you directly insert data using SQL statements in the database, the Chinese characters are displayed normally, how can this problem be solved? The data encoding process and principles of MySQL are not described here. If you are interested, you can use Baidu.
The following operations are available:
1. Open the mysql console and enter the command show variables like 'character % ';
Shown as follows:
+--------------------------+-------------------------------------------+| Variable_name | Value |+--------------------------+-------------------------------------------+| character_set_client | latin1 || character_set_connection | latin1 || character_set_database | utf8 || character_set_results | latin1 || character_set_server | utf8 || character_set_system | utf8 || character_sets_dir | C:\MySQL\MySQL Server 5.0\share\charsets\ |+--------------------------+-------------------------------------------+
2. Modify the my. ini file
[client] default-character-set=utf8 [mysqld] default-storage-engine=INNODB character-set-server=utf8 collation-server=utf8_general_ci
3. Run the command in step 1 After restart as follows:
+--------------------------+----------------------------+| Variable_name | Value |+--------------------------+----------------------------+| character_set_client | utf8 || character_set_connection | utf8 || character_set_database | latin1 || character_set_filesystem | binary || character_set_results | utf8 || character_set_server | latin1 || character_set_system | utf8 || character_sets_dir | /usr/share/mysql/charsets/ |+--------------------------+----------------------------+
The default Character Set of character_set_database and character_set_server is latin1.
4. Enter the command: set names utf8;
After the restart, run the following command:
+--------------------------+------------------------------------------------+| Variable_name | Value |+--------------------------+------------------------------------------------+| character_set_client | utf8 || character_set_connection | utf8 || character_set_database | utf8 || character_set_filesystem | binary || character_set_results | utf8 || character_set_server | utf8 || character_set_system | utf8 || character_sets_dir | C:\wamp64\bin\mysql\mysql5.7.9\share\charsets\ |+--------------------------+------------------------------------------------+
Except character_set_filesystem is binary, all others are utf8,
In this way, you can enter the database normally by setting utf8 encoding on the web end.
The above section describes how to solve the problem of Mysql5.7 Chinese garbled characters. I hope it will help you. If you have any questions, please leave a message and I will reply to you in a timely manner. Thank you very much for your support for the help House website!