mysql修改編碼(數據庫,表,字段)

  • 查看各個編碼
    //查看字段編碼
    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;
相關文章
相關標籤/搜索