Solve the problem of mysql garbled characters

Solve the problem of mysql garbled characters

I bought a server yesterday, so I rebuilt the environment

The operating system is cent os (a kind of Linux), and jdk, svn, git, mysql, etc. must be installed.

After mysql is installed, the original java web project is garbled.

 

 

The first pit: /etc/my.cnf

The mysql database is developed by foreigners, so the default is latin1 encoding, similar to ISO-8859-1,

But we Chinese are used to using Chinese, so we need to modify the code:



 The content in the red box is what I added manually:

Add under [mysqld]:

character_set_server=utf8  

If you add default-character-set=utf8, the mysql service cannot be started.

 

New node:

[mysql]

default-character-set=utf8

By default there is no [mysql] node

 

The second pit: client Navicat

After using Navicat's own function "Data Transfer" to transfer data from the original database to the new database, the Web project is always garbled.

 

Very strange: when viewing the data table in Navicat, is it not garbled; but when viewing the Java web program, it is garbled; and when using the Java web program to add a record, it is not garbled, but when viewing the new record in Navicat, it is a question mark (?? ).

In the end, it was found that it was a problem with Navicat's settings.

 



 

 

 

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326609880&siteId=291194637