mysql安装后修改编码格式
Posted on: 2015-06-13, Last modified: 2015-07-30, View: 1642

mysql在初始安装后默认编码为Latin1, 不支持中文,要把编码修改为gbk或者utf8才可以。

登录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 | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+

修改编码步骤:

1、使用命令service mysqld stop 或者/etc/init.d/mysql start (stop) 停止mysql

2、修改mysql配置文件my.conf, 一般位置在/etc下找到客户端配置[client] 在下面添加
default-character-set=utf8 默认字符集为utf8
在找到[mysqld] 添加
default-character-set=utf8 默认字符集为utf8
init_connect='SET NAMES utf8' (设定连接mysql数据库时使用utf8编码,以让mysql数据库为utf8运行)

3、重启mysql即可

 

 

 

Go
Friend Links:
Bill Site
https://item.taobao.com/item.htm?spm=a21an.7676007.1998473182.296.lAvrE2&id=45399580446