I. Description
After MySQL database connection is converted by encoding on the designer, when Chinese data is entered into the database through report entry, garbled characters always appear. How to solve this?
II. Solution
1. Refer to and modify MySQL character set
1) View MySQL data character set
Introduction to MySQL Character Set: There are two aspects to MySQL Character Set Support: Character set and Collation.
The support for character sets is refined to four levels: Server, Database, Table, Connection.
View the default character set (by default, MySQL's character set is latin1(ISO_8859_1)
Usually, the setting of viewing system character set and sorting method can be achieved by the following two commands:
SHOW VARIABLES LIKE 'character%';//View character set
As shown below:
SHOW VARIABLES LIKE 'collation_%';//View sorting method
As shown below:
2) Modify MySQL character set
method one:
Modify the character set key value in MySQL's my.ini file.
default-character-set = utf8 character_set_server = utf8
After modification, restart the MySQL service, service mysql restart, use
mysql> SHOW VARIABLES LIKE 'character%';
Check it and find that the database encoding has been changed to UTF-8.
Method Two:
Use SQL commands
SET character_set_client = utf8 ; SET character_set_connection = utf8 ;
Note: if the four characters of character_set_connection, database, results, server are the same, there is no need for garbled characters. The above method to modify the character set is under the Windows system, if it is a Linux system, use the method under Linux, the idea is the same.
After the modification is completed, check the character encoding through
show variables like 'character_set_%'
, if there is still a garbled problem after modification. You need to modify the number of data connections in the designer.
2. Data connection modification
Add parameters where you define the data connection and add the URL
?useUnicode=true&characterEncoding=UTF-8
as follows:
Note that the encoding in the illustration needs to be set to automatic. In general, the problem of garbled encoding parameters can be solved here in the data connection. If it has not been solved, look down.
3. Check the default font of the system
For example, check the font style of C:\WINDOWS\Fonts\under Windows,As shown below:
If you don’t have the above fonts, Baidu will lack the fonts to install by yourself. After installation, if you still have problems with the above fonts, you need to refer to and modify the MySQL character set.
Keywords: MySQL Chinese garbled