Chinese garbled problem
when I first contact MySQL, first let me uncomfortable is the MySQL garbled problem, Baidu also has a lot of related solutions, but as a personal victim, I think it is necessary to post my voice:
1. About MySQL's character set processing
MySQL takes binary and non binary character formats when identifying data, which is used primarily to identify pictures, sounds, and the latter to complete all remaining functions, and for the latter, character set problems exist.
We know that the database is made by foreigners, they did not take into account the design of the coding format, in the modern computer popular each country in order to support their own language, have introduced their own coding format, the following use the MySQL command to list all the world's code:
The GBK, gb2312 and Big5 are Chinese codes.
GBK: Support More than 21,000 Chinese characters, including simplified and traditional, accounting for 2 bytes
GB2312: Support More than 6,700 Chinese characters, accounting for 2 bytes
Big5: Support the traditional character set, mainly support Hong Kong, Taiwan, the other side of the characters, traditional, more than 13,000 Chinese characters, 2 bytes
The International Organization for Standardization (ISO) creates a UTF8 encoding, a format called the Universal code, that supports all language-specific solutions in the world in order to unify the format:
First use the command line to view the character set:
Explain the garbled principle:
When we link to the MySQL database, we actually go through the following steps:
Client-> link-side-> database field end-> return end
It's in the map above.
Character_set_client
character_set_connection
character_set_database
character_set_result
Garbled problem occurs in these several steps, as long as one of the steps of error, will appear garbled
When we use the program in the external link MySQL database, the client is our program software, so to set the client to GBK or gb2312, the link is set to UTF8 or GBK, the database is set to GBK or UTF8
Return to set to GBK, so generally will not appear in Chinese garbled
As shown in the following illustration:
You can set it through the command line:
If you do not consider the injection problem, you can take the following methods:
This command sets the client, the connection end, the return end is GBK;
You can also set individual settings:
Set up the character set when you create the library:
Use the command:
Create DATABASE mydatabase default character set UTF8;
Specify the character set of the table when you create the table:
Use the command:
CREATE table User (name char () character set GBK) default character set GBK;
There are also the following settings:
To set the result set:
Set CHARACTER_SET_RESULTS=GBK;
To set the connection character set:
Set CHARACTER_SET_CONNECTION=GBK;
Because we are now learning phase, regardless of memory capacity issues, unified set for UTF8, if your program only supports Chinese, your work to release the best choice GBK coding ....
If you follow the above method or discover that the program is running a problem, check that your program is also a Unicode encoding, which is why I used to be.
Start a service issue
I now assume that you created the login user and password when you installed the MySQL database (MySQL is free to download to the website)
Install the completed MySQL database is automatically run, if your MySQL database service accidentally shut down, you can take the following solutions:
Scenario 1: Click the right mouse button on the desktop computer icon,
Manage-> services and Applications-> services and then find the MySQL service entry in the list, right-click to perform "Start", and of course you can stop MySQL service here.
Programme 2:
Open cmd (command line) and execute the command:
Note: The mysql55 here is the MySQL database service name on my PC, specifically to follow the database service name of my PC ... This service name is the name of the service you specified for installing the MYSQ database.