DBA-mysql-字符集

查看支持的字符集:show charset;

查看现使用字符集:status;

1.在[mysqld]下添加

default-character-set=utf8 (mysql 5.1版本)

character-set-server=utf8(mysql 5.5 5.6 5.7版本)
 

库.字段.表

修改数据库字符集:ALTER DATABASE test CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; 

修改表默认字符集:ALTER TABLE test DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

修改字段的字符集:ALTER TABLE test CHANGE title title VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci; 

查看库的默认字符集:SHOW CREATE DATABASE mysql;

查看表的默认字符集:SHOW CREATE Table user;

查看字段的默认字符集:SHOW FULL COLUMNS FROM user

 

查看字符集设置:show variables like 'character%';

set character_set_database=utf8;

set character_set_server=utf8;

*:重启mysql后无效全局设置无效

创建数据库时指定字符集

Create database air_1 default character set gbk collate  gbk_chinese_ci;

Create database air_2 default character set utf8 collate  utf8_general_ci;

posted on 2017-01-05 13:12  baxk2001  阅读(218)  评论(0编辑  收藏  举报

导航