First of all, MySQL's character set problem. Windows can be modified by modifying the My.ini within the
Default-character-set=utf8 //client's default character set
Enter in the MySQL client tool
Shows the following
This performs read information returned to Chinese as garbled, the solution is, after connecting the database, read the data, first execute a query SET NAMES ' UTF8 '; can be displayed correctly.
The simplest and most perfect way to modify the character set key values in the MySQL my.cnf file (note the details of the configured fields):
1. Add Default-character-set=utf8 to the [client] field as follows:
Port = 3306
socket =/var/lib/mysql/mysql.sock
Default-character-set=utf8
2. Add the Character-set-server=utf8 in the [mysqld] field as follows:
Port = 3306
socket =/var/lib/mysql/mysql.sock
Character-set-server=utf8
3, in the [MySQL] field to add Default-character-set=utf8, as follows:
No-auto-rehash
Default-character-set=utf8
After the modification is complete, the service MySQL restart restart MySQL services will take effect. Note: The [mysqld] field differs from the [MySQL] field. No one has been feedback on the Internet.
Use show VARIABLES like ' character% '; Check to see that the database code has been changed to UTF8.
+--------------------------+----------------------------+
| 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 | /usr/share/mysql/charsets/|
+--------------------------+----------------------------+
4, if the above are all modified also garbled, the remaining problems must be on the connection connection layer. The workaround is to execute the following sentence (written directly at the front of the SQL file) before sending the query:
It corresponds to the following three-sentence instruction:
SET character_set_client = UTF8;
SET character_set_results = UTF8;
SET character_set_connection = UTF8;
Many other methods on the Internet can not completely solve this problem, this could be a perfect solution!