查看MysqL知识库" href="http://lib.csdn.net/base/MysqL" target="_blank">数据库的排序规则
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)
<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)
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;