MySQL character encoding setting method
- 2021-01-14 06:54:49
- OfStack
By show variables like 'character_set%%'; Check the code
There are several ways to modify mysql encoding:
1. Modify my.ini(windows) or /etc/my.cnf(linux) by 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 the encoding when creating the database
create database test character set utf8;
3. Set the encoding when creating the table
create table test(id int primary key)DEFAULT charset=utf8;
4. Change the database encoding
alter database test character set utf8;
Alter table default encode
alter table test character set utf8;
6. Change the field encoding
alter table test modify col_name varchar(50) CHARACTER SET utf8;
The above is this site to introduce MySQL character encoding setting method, I hope to help you!