mysql修改编码(数据库,表,字段)

时间:2022-07-23 07:23:42
  • 查看各个编码
    //查看字段编码
    SHOW FULL COLUMNS from park_car_user;
    //查看数据库字段
    SHOW CREATE DATABASE db_name;
    //查看表的编码
    SHOW CREATE TABLE tbl_name;
  • 修改数据库编码
[client] 
default-character-set=gbk 
port=3306 
[server] 
default-character-set=gbk 
port=3306 
[mysql] 
default-character-set=gbk 
[mysqld] 
port=3306 
basedir=C:/Program Files/MySQL/mysql/
datadir=C:/Program Files/MySQL/mysql/data/
default-character-set=gbk 
default-storage-engine=INNODB 

 

  • 修改表的编码
ALTER TABLE tbl_name DEFAULT CHARACTER SET charset_name [COLLATE collation_name];
  • 修改字段编码
//修改表中所有字段的编码为utf8
ALTER TABLE park_car_user CONVERT TO CHARACTER SET utf8;