mysql绿色版安装修改字符集_修改非安装版本mysql字符集

D:\mysql\mysql-5.1.40-win32\bin>mysqld --console

如果能看到

Version: '5.1.40-community-log' socket: '' port: 3306 MySQL Community Server

(GPL)

说明mysql服务启动成功。

连接mysql

同样在mysql的bin目录下执行命令:

D:\mysql\mysql-5.1.40-win32\bin>mysql -u root -p

Enter password: ************

登录成功后执行命令:

mysql> show variables like 'character%';

显示

mysql> show variables like 'character%';

+--------------------------+---------------------------------------------+

| 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 | latin1 |

| character_set_system | utf8 |

| character_sets_dir | D:\mysql\mysql-5.1.40-win32\share\charsets\ |

+--------------------------+---------------------------------------------+

8 rows in set (0.06 sec)

mysql字符集默认为Latin1,为了避免中文乱码,我们修改my.cnf配置文件即可。

找到[client] 添加:

default-character-set=utf8 //默认字符集为utf8

找到[mysqld] 添加:

//默认字符集为utf8

default-character-set=utf8

//设定连接mysql数据库时使用utf8编码,以让mysql数据库为utf8运行

init_connect='SET NAMES utf8'

重启mysql,再次查看

mysql> show variables like 'character%';

+--------------------------+---------------------------------------------+

| Variable_name            | Value                                       |

+--------------------------+---------------------------------------------+

| character_set_client     | utf8                                        |

| character_set_connection | utf8                                        |

| character_set_database   | utf8                                        |

| character_set_filesystem | binary                                      |

| character_set_results    | utf8                                        |

| character_set_server     | utf8                                        |

| character_set_system     | utf8                                        |

| character_sets_dir       | D:\mysql\mysql-5.1.40-win32\share\charsets\ |

+--------------------------+---------------------------------------------+

8 rows in set (0.00 sec)

ok,字符集成功修改。

分享到:

18e900b8666ce6f233d25ec02f95ee59.png

72dd548719f0ace4d5f9bca64e1d7715.png

2009-12-08 08:08

浏览 1772

评论

1 楼

partoo

2010-02-25

辛苦了~

38687d1a1ad71d37c86f287056834d1a.gif

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值