Home > Database > Mysql Tutorial > Ubuntu12.0.4 Linux服务器部署之 修改MySQL字符集 5.x_MySQL

Ubuntu12.0.4 Linux服务器部署之 修改MySQL字符集 5.x_MySQL

WBOY
Release: 2016-06-01 13:07:11
Original
790 people have browsed it

Ubuntu

进入mysql安装目录并找到配置文件, /etc/mysql/my.cnf文件

使用命令:

sudo vi my.cnf
Copy after login

进入修改配置文件, 

1-在[client]节点下面添加

# 默认字符集为utf8default-character-set=utf8 
Copy after login

2-在[mysqld] 节点下添加

# 默认字符集为utf8default-character-set=utf8 #设定连接mysql数据库时编码, 让mysql数据库为utf8运行init_connect='SETNAMES utf8' 
Copy after login

 

修改好后,重启mysql 即可,查询一下

使用下面命令

show variables like 'character%';
Copy after login

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

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

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

注:mysql 5.5

解决办法是在my.cnf文件的[mysqld]配置选项下添加如下内容, 就可以了。

character-set-server= utf8lower_case_table_names= 1
Copy after login



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