mysql modify encoding (database, table, field)

  • View individual codes
    //View field code
    SHOW FULL COLUMNS from park_car_user;
    //View database field 
    SHOW CREATE DATABASE db_name;
    //View the encoding of the table 
    SHOW CREATE TABLE tbl_name;
  • Modify database encoding
[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 

 

  • Modify the encoding of the table
ALTER TABLE tbl_name DEFAULT CHARACTER SET charset_name [COLLATE collation_name];
  • Modify field encoding
//Modify the encoding of all fields in the table to utf8
ALTER TABLE park_car_user CONVERT TO CHARACTER SET utf8;

 

Guess you like

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