Home > Database > Mysql Tutorial > body text

Linux下修改MySQL编码的方法

WBOY
Release: 2016-06-07 18:06:57
Original
905 people have browsed it

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

默认登录mysql之后

  mysql> show variables like '%character%';

  把/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.cnf

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

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

  

  即使做了以上修改如果直接数据库再创建表,然后存入中文,取出来的会是问号。解决的办法是:创建数据库的时候指明默认字符集为utf8,如:

  create database test default character set utf8;

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!