这篇文章主要为大家展示了“MySQL中文如何配置”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“MySQL中文如何配置”这篇文章吧。
1. 表中字段的字符集设置 。show create table TableName 或 show full columns from tableName
> 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=gbk |
+-------+------------------------------------
1 row in set (0.00 sec)
mysql> show full columns from t1;
+-------+-------------+----------------+------+-----+-
| Field | Type | Collation | Null | Key |
+-------+-------------+----------------+------+-----+-
| id | int(11) | NULL | NO | PRI |
| c1 | varchar(30) | gbk_chinese_ci | YES | |
+-------+-------------+----------------+------+-----+-
2 rows in set (0.00 sec)
mysql>
2. 当前联接系统参数 show variables like 'char%'
mysql> show variables like 'char%';
+--------------------------+----------------
| Variable_name | Value
+--------------------------+----------------
| character_set_client | gbk
| character_set_connection | gbk
| character_set_database | latin1
| character_set_filesystem | binary
| character_set_results | gbk
| character_set_server | latin1
| character_set_system | utf8
| character_sets_dir | C:/Program File
+--------------------------+----------------
8 rows in set (0.00 sec)
mysql>
a. 中文,请确保 表中该字段的字符集为中文兼容:
big5 | Big5 Traditional Chinese
gb2312 | GB2312 Simplified Chinese
gbk | GBK Simplified Chinese
utf8 | UTF-8 Unicode
b. 确保,联接参数与这个字段字符集一致,你可以用 set name 'charsetname';
比如, set name 'gbk';
这条命令会同时修改 character_set_client,character_set_connection,character_set_results
(如果你的这架MySQL中都为中文,则你可以在my.ini或my.cnf中加上或修改这个参数, 参数文件修改后需重启MySQL服务)
[mysql]
default-character-set=utf8;
以上是“MySQL中文如何配置”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注亿速云行业资讯频道!