Home > Database > Mysql Tutorial > body text

在RHEL6.3下解决MySQL中文乱码

WBOY
Release: 2016-06-07 17:30:24
Original
893 people have browsed it

为了省去以后麻烦,这里我们在RHEL6.3下配置文件里修改mysql乱码问题。我的mysql配置文件是/etc/my.cnf

为了省去以后麻烦,,这里我们在RHEL6.3下配置文件里修改mysql乱码问题。我的mysql配置文件是/etc/my.cnf

1.首先在配置文件中找到[mysqld],添加如下一行:

[mysqld]

character_set_server=utf8

2.然后找到[mysql]这个选项,在我这里是没有这个选项的,有的不必添加,我添加了如下:

[mysql]

default-character-set=utf8

3.重启mysql服务

[root@mysql ~]# /etc/init.d/mysqld restart

停止 mysqld:                                              [确定]

正在启动 mysqld:                                          [确定]

4.进入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 | /usr/share/mysql/charsets/ |

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

8 rows in set (0.00 sec)

5.如果还不行手工设置,设置命令如下:

mysql>SET character_set_client=utf8 ; 
mysql>SET character_set_connection=utf8 ; 
mysql>SET character_set_database=utf8 ; 
mysql>SET character_set_results=utf8 ;   
mysql>SET character_set_server=utf8 ; 
mysql>SET collation_connection=utf8 ; 
mysql>SET collation_database=utf8 ; 
mysql>SET collation_server=utf8 ;

相关阅读:

CentOS(Linux)中解决MySQL乱码

Fedora 15下MySQL乱码问题解决

linux

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!