Home > Database > Mysql Tutorial > body text

Linux下MySQL编码的修改_MySQL

WBOY
Release: 2016-06-01 13:42:42
Original
1036 people have browsed it

bitsCN.com
默认登录mysql之后可以通过SHOW VARIABLES语句查看系统变量及其值。  mysql> show variables like '%character%';
Linux下MySQL编码的修改_MySQL
 说明:以下是在CentOS-6.2下的设置  (不同的版本可能有些差异,比如文件的位置。但设置的内容应该是一样的)
 1. 找到mysql的配置文件,拷贝到etc目录下,第一步很重要  把/usr/share/doc/mysql-server-5.1.52/my-large.cnf 复制到 /etc/my.cnf  即用命令:cp /usr/share/doc/mysql-server-5.1.52/my-large.cnf  /etc/my.cnf2. 打开my.cnf修改编码  在[client]下增加default-character-set=utf8  在[mysqld]下增加default-character-set=utf8  同时加上init_connect='SET NAMES utf8' (设定连接mysql数据库时使用utf8编码,以让mysql数据库为utf8运行)    
Linux下MySQL编码的修改_MySQL 3.重新启动mysql  service mysqld restart  再次输入show variables like '%character%';
Linux下MySQL编码的修改_MySQL   即使做了以上修改如果直接数据库再创建表,然后存入中文,取出来的会是问号。解决的办法是:创建数据库的时候指明默认字符集为utf8,如:  create database test default character set utf8;   作者 GNU夜未眠 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