Home > Database > Mysql Tutorial > body text

Linux下修改MySQL编码的方法_MySQL

WBOY
Release: 2016-06-01 13:36:38
Original
960 people have browsed it

bitsCN.com


有时候因为编码需要修改mysql的编码,windows下修改有图文界面简单一些,linux大家就
可以参考下面的方法。

默认登陆MySQL后,可以通过SHOW VARIABLES语句查看系统环境变量及其值。

mysql> show variables like '%char%';
 

Linux下修改MySQL编码的方法_MySQL

1. 找到mysql的配置文件,复制到etc目录。

    把/usr/share/doc/mysql-server-5.1.66中的my-large.cnf复制到/etc/my.cnf

2. 打开my.cnf,修改编码

    在[client]下,增加default-character-set=utf8

在[mysqld]下增加default-character-set=utf8 和 init_connect='SET NAMES utf8'

 

Linux下修改MySQL编码的方法_MySQL

 

3. 重启mysql

    service mysqld restart 或 /etc/init.d/mysqld restart

    再次输入show variables like '%char%';

Linux下修改MySQL编码的方法_MySQL

 

在创建数据库时,最好指明数据库默认字符集为utf8:create database test default character set utf8;
 

bitsCN.com
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