The reason for the problem is that the default connection is gbk encoding
The solution is as follows: Find the mysql configuration file my.cnf, and then configure it as follows:
Client configuration [client] Add default-character-set=utf8 below //The default character set is utf8 Find [mysqld] and add default-character-set=utf8 //The default character set is utf8 init_connect= 'SET NAMES utf8' //(Set to use utf8 encoding when connecting to the mysql database so that the mysql database runs as utf8)
Then restart mysql, and then run the command just now. After it is utf-8, you can directly use insert into in the java program without the need for the previous set names
The reason for the problem is that the default connection is gbk encoding
The solution is as follows:
Find the mysql configuration file my.cnf, and then configure it as follows:
Client configuration [client] Add
default-character-set=utf8 below //The default character set is utf8
Find [mysqld] and add
default-character-set=utf8 //The default character set is utf8
init_connect= 'SET NAMES utf8' //(Set to use utf8 encoding when connecting to the mysql database so that the mysql database runs as utf8)
Then restart mysql, and then run the command just now. After it is utf-8, you can directly use insert into in the java program without the need for the previous set names