【Mysql】Character set setting

View character set

SHOW VARIABLES LIKE 'character%'

 



 

(1) The simplest modification method is to modify the character set key value in the my.ini file of mysql,

Such as

default-character-set = utf8 

character_set_server = utf8

After modification, restart the mysql service, service mysql restart

 

(2) Another way to modify the default character set of mysql is to use the mysql command

SET character_set_client = utf8 ;

SET character_set_server = utf8 ;

 

Generally, even if the default character set of mysql for the table is set to utf8 and the query is sent through UTF-8 encoding, you will find that the data stored in the database is still garbled. The problem lies in the connection layer. The solution is to execute the following sentence before sending the query:

SET NAMES 'utf8';  

It is equivalent to the following three commands:

SET character_set_client = utf8;  

SET character_set_results = utf8;   

SET character_set_connection = utf8; 

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326400106&siteId=291194637