Mysql garbled Solution
First, enter mysql> show variables like 'Char % 'in mysql editing mode under the command line to view the character set settings of the database.
Client, connection, and result are related to the command line client (gbk must be set for the command line client in windows)
Database server system and server-related character sets (the system character set cannot be modified) * In actual development, we recommend that you set the database and server character sets to utf8. After modifying the database server system and server-related character sets, You need to restart mysql to take effect. You can also restart the mysql service, in the command line: stop command: net stop mysql start command: net start mysql
Mysql core configuration file my. ini if linux my. cnf
[Mysql] mainly configures the command line client parameter default-character-set = gbk ---- affects the client, connection, and result
[Mysqld] configuring the server parameter character-set-server = utf8 ----- affects database server
Note: If Windows 7 is used, you can copy the file and put the modification back because of permission issues. (This problem occurs when mysql is installed on disk C)
If utf8 has been set for the server character set to create a database data table, the default utf8 ----- the inserted data must not contain garbled characters.
If the server does not set the server character set, the default value is latin1. If the database is created and the specified character set is UTF-8, the table is created and the specified character set is UTF-8 (garbled)
Solution 1: Set the server Character Set and recreate the database and table
Solution 2: jdbc: mysql: // db? UseUnicode = true & characterEncoding = UTF-8 (default transport Character Set utf8/gbk)