LinuxC program inserts Chinese data garbled into MySQL. First, read the article "Cannot display MySQL Chinese Characters in Linux and solve sock Link errors" w
Linux C Programming inserts Chinese data garbled into MySQL. First read the article "Cannot display MySQL Chinese Characters in Linux and solve sock Link errors" http: // w
Linux C Programming inserts Chinese data garbled into MySQL.
First read this article titled "Cannot display MySQL Chinese characters and solve sock Link errors in Linux ".
After the above changes, you should add this sentence before inserting data into the database in the C program:
Mysql (conn, "set names \ 'utf8 \'");
In this way, no garbled code will be generated.
Character_set_client: Character Set of the Client
Character_set_results: Result Character Set
Character_set_connection: Connection Character Set
Command for setting these three system parameters: set names 'utf8'
Functions of these three system parameters:
Information Input path: client -- connection -- server (data transmission direction from left to right)
Information output path: server -- connection -- results (data transmission direction from left to right)
Therefore, the values of these system parameters must be the same. Otherwise, data is transmitted in different encoding methods. If the encoding method is incompatible, garbled characters may occur.