以下以Navicat for Mysql为例如何设置mysql客户端编码为UTF-8:
选择test数据库,右键数据库属性,字符集下拉选择utf8,如下:
修改好,关闭test数据库,重新打开,把之前的表编码修改成utf-8
插入一条含有中文的数据,成功插入,查询结果,已没有乱码出现。
方法一:mysql>show variables like '%chara%'
+--------------------------+--------------------------+
| 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 | d:\mysql\share\charsets\ |
+--------------------------+--------------------------+
8 rows in set (0.00 sec)
mysql>set character_set_client=utf8
->
Query OK, 0 rows affected (0.00 sec)
mysql>set character_set_client=gbk
Query OK, 0 rows affected (0.00 sec)
mysql>
方法二:
在my.ini或者my.cnf中改
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)