Home > Database > Mysql Tutorial > body text

在Ubuntu中向MySQL插入中文数据

WBOY
Release: 2016-06-07 16:55:46
Original
1032 people have browsed it

在Ubuntu中向MySQL插入数据,保证插入中文可以按如下步骤: 1. 停止MySQL服务:sudo /etc/init.d/mysql stop 2. 编辑MySQL配置文

在Ubuntu中向MySQL插入数据,保证插入中文可以按如下步骤:

1. 停止MySQL服务:sudo /etc/init.d/mysql stop

2. 编辑MySQL配置文件:sudo gedit /etc/mysql/my.cnf

3. 在 [client],, [mysqld_safe], [mysql] 等段中加入 default-character-set=utf8

4. 重新启动MySQL服务: sudo /etc/init.d/mysql start  

相关阅读:Ubuntu MySQL插入中文出错

检测:

进入mysql,输入 mysql> show variables like '%char%';

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

如果出现以上这种结果,说明成功配置

linux

Related labels:
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