查看的排序规则
mysql show variables
Variable_name Value
collation_connection utf8_general_ci
collation_database utf8_general_ci
collation_server latin1_swedish_ci
rows ( sec)
查看数据库的编码格式
mysql show variables
Variable_name Value
character_set_client utf8
character_set_connection utf8
character_set_database utf8
character_set_filesystem
character_set_results utf8
character_set_server latin1
character_set_system utf8
character_sets_dir usrsharemysqlcharsets
rows ( sec)
查看字段的排序规则
mysql show tablename;
查看表字段信息
mysql tablename;
查看当前数据库编码
mysql mysql<span style=”color: #808080;”>> show variables <span style=”color: #808080;”>like <span style=”color: #ff0000;”>'<span style=”color: #ff0000;”>character_set_database<span style=”color: #ff0000;”>'<span style=”color: #000000;”>;
<span style=”color: #808080;”>+<span style=”color: #008080;”>–<span style=”color: #008080;”>———————-+——-+
<span style=”color: #808080;”>| Variable_name <span style=”color: #808080;”>| Value <span style=”color: #808080;”>|
<span style=”color: #808080;”>+<span style=”color: #008080;”>–<span style=”color: #008080;”>———————-+——-+
<span style=”color: #808080;”>| character_set_database <span style=”color: #808080;”>| utf8 <span style=”color: #808080;”>|
<span style=”color: #808080;”>+<span style=”color: #008080;”>–<span style=”color: #008080;”>———————-+——-+
<span style=”color: #800000; font-weight: bold;”>1 row <span style=”color: #808080;”>in <span style=”color: #0000ff;”>set (<span style=”color: #800000; font-weight: bold;”>0.03 sec)
修改当前数据库的编码
mysql mysql<span style=”color: #808080;”>> <span style=”color: #0000ff;”>alter <span style=”color: #0000ff;”>database databasename <span style=”color: #0000ff;”>character <span style=”color: #0000ff;”>set<span style=”color: #000000;”> latin1; #将之前的utf8编码修改为latin1编码
Query OK,<span style=”color: #800000; font-weight: bold;”>1 row affected (<span style=”color: #800000; font-weight: bold;”>0.00<span style=”color: #000000;”> sec)
<span style=”color: #808080;”>+<span style=”color: #008080;”>–<span style=”color: #008080;”>———————-+——–+
<span style=”color: #808080;”>| Variable_name <span style=”color: #808080;”>| Value <span style=”color: #808080;”>|
<span style=”color: #808080;”>+<span style=”color: #008080;”>–<span style=”color: #008080;”>———————-+——–+
<span style=”color: #808080;”>| character_set_database <span style=”color: #808080;”>| latin1 <span style=”color: #808080;”>|
<span style=”color: #808080;”>+<span style=”color: #008080;”>–<span style=”color: #008080;”>———————-+——–+
<span style=”color: #800000; font-weight: bold;”>1 row <span style=”color: #808080;”>in <span style=”color: #0000ff;”>set (<span style=”color: #800000; font-weight: bold;”>0.00 sec)
查看字段编码
SHOW COLUMNS tablename;
修改字段的字符集
tablename CHANGE c_name c_name character_name users CHANGE title title () utf8 COLLATE utf8_general_ci;