MySQL character encoding and mysql character setting
Use show variables like 'character _ set % '; to view the Encoding
You can modify the encoding method of mysql as follows:
1. modify my. ini (in windows) or/etc/my. cnf (in linux) through the configuration file)
Add the following content separately
[Mysqld] character_server_set = utf8 [mysql] default-character-set = utf8 [mysql. server] default-character-set = utf8 [mysql_safe] default-character-set = utf8 [client] default-character-set = utf8
2. Set encoding when creating a database
Create database test character set utf8;
3. Set the encoding when creating a table
Create table test (id int primary key) DEFAULT charset = utf8;
4. Modify the database code
Alter database test character set utf8;
5. Modify the default table encoding.
Alter table test character set utf8;
6. Modify the field encoding.
Alter table test modify col_name varchar (50) character set utf8;
The preceding section describes how to set up MySQL character encoding. I hope it will be helpful to you!