Today, the original MySQL garbled problem, the past is always a hasty solution to forget. I can't stand it this time. Every time it was a change of a daze. This decision to explore a good, read a lot of information and blog after understanding the point. Record them first. If there is something wrong, please correct me. 1. MySQL first supports multiple character sets after 4.0. So only after 4.0 will this problem occur. The rule of the encoding transformation is to convert the encoding from "client code" to "server-side encoding" when the data is entered, and the output to convert the data from "server-side encoding" to "client encoding."
The character set processing for MySQL is this:
1, send the request.
1) The client sends the request to the server side.
2) The server will transfer the requested data from the client character set (character_set_client) to the server connection character set (Character_set_connection).
3) The server then detects the character set of the storage area (table,column) and then shifts the data from the connection character set (character_set_connection) to the character set of the storage area (Table,column) and then stores or queries.
2, return the request.
1) The server converts the character set of the storage area (Table,column) to the server connection character set (Character_set_connection).
2) Convert the server connection character set (character_set_connection) to the result character set (Character_set_results) and send to the client.
First, let's look at the mysql>status;.
We can see the settings for four character sets. 1. Changing the encoding in the My.ini file can change all character sets. 2.set names "Uf8" can change the Client Conn these two character sets. 3. The setting code of the database can change the db. I know, after the principle I began to solve the problems encountered today. 1. Display Chinese normally in other places. However, it is not possible to display garbled characters in CMD. First I set the My.ini to set all the character sets to UTF8. Personal feeling UTF8 is the trend of standard. The database is then set to UTF8 when it is established. But see the cmd query is garbled. This is because CMD, which is known as DOS in Windows, does not support UTF8. so I set the output to the client encoding mode to convert to GBK. That is set names GBK. Ok problem solved.
MySQL Database garbled summary