我用的是MySQL5.1和MySQL Query Browser 1.1。
MySQL中默认字符集的设置有四级:服务器级,数据库级,表级 。最终是字段级 的字符集设置。注意前三种均为默认设置,并不代表你的字段最终会使用这个字符集设置。
1、查看表级设置
方法一,选择一个表,点击“Table Options”,下方有个“Character Set”,“Charset”选择gb2312。
方法二,在MySQL Command Line Client中输入。
mysql> show create table t1;
+-------+------------------------------------
| Table | Create Table
+-------+------------------------------------
| t1 | CREATE TABLE `t1` (
`id` int(11) NOT NULL,
`c1` varchar(30) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=gb2312 |
+-------+------------------------------------
1 row in set (0.00 sec)
2、查看字段级设置
方法一,编辑一个表,在Columns and Indices中选择一个字段,在下方选择Column Details->Column Charset选择gb2312。
方法二,在MySQL Command Line Client中输入。
mysql> show full columns from t1;
+-------+-------------+----------------+------+-----+-
| Field | Type | Collation | Null | Key |
+-------+-------------+----------------+------+-----+-
| id | int(11) | NULL | NO | PRI |
| c1 | varchar(30) | gb2312_chinese_ci | YES | |
+-------+-------------+----------------+------+-----+-
2 rows in set (0.00 sec)
3、当前联接系统参数 show variables like 'char%'
mysql> show variables like 'char%';
+--------------------------+----------------
| Variable_name | Value
+--------------------------+----------------
| character_set_client | latin1
| character_set_connection | latin1
| character_set_database | latin1
| character_set_filesystem | binary
| character_set_results | latin1
| character_set_server | gb2312
| character_set_system | utf8
| character_sets_dir | C:/Program File
+--------------------------+----------------
8 rows in set (0.00 sec)
mysql>
在MySQL目录下修改my.ini文件的default-character-set=gb2312,可以修改
character_set_client,character_set_connection,character_set_results的值为gb2312