First, display the garbled characters, mainly Chinese garbled characters:
Step 1: Find the directory where mysql is installed and find the my.ini file;
Step 2: Use Notepad to open the my.ini file and set the default encoding to utf-8:
Step three: Enter in the mysql database cmd: show variables like'%char%';
## Step four: Change the encoding method of the original database: Step 5: Changed encoding method: Step 6: Query again: Several character sets involved in MySQLcharacter-set-server/default-character-set: Server character set, used by default.character-set-database: Database character set.
character-set-table: Database table character set.
The priorities increase in sequence. Therefore, generally you only need to set the character-set-server, and do not specify the character set when creating databases and tables. In this way, the character-set-server character set is uniformly used.
character-set-client: The client’s character set. Client default character set. When a client sends a request to the server, the request is encoded in this character set.
character-set-results: Result character set. When the server returns results or information to the client, the results are encoded in this character set.
On the client side, if character-set-results is not defined, the character-set-client character set is used as the default character set. So you only need to set the character-set-client character set.
character_set_client: The client’s character set.
character_set_results: Result character set.
character_set_connection: Connection character set.
Set these three system parameters by sending statements to MySQL: set names gb2312