标签:
摘要:Ubuntu Server 服务器下使用apt-get 命令安装的mysql,默认不是utf8、在这里记录一下如何将编码修改成utf8。
办法解决:
show variables like ‘%character%‘;
+--------------------------+----------------------------+ | 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/ | +--------------------------+----------------------------+
默认情况下使用apt-get 下载安装的mysql编码 并非utf8,这在开发中非常的蛋疼!!
a) 打开mysql配置文件:
vim/etc/mysql/my.cnf
b) 在[client]下追加:
default-character-set=utf8
c) 在[mysqld]下追加:
character-set-server=utf8
d) 在[mysql]下追加:
default-character-set=utf8
e) 保存并退出
service mysql restart
a.登录MySQL
mysql -u username -p
b.查看编码
show variables like ‘%character%‘;
标签:
原文地址:http://www.cnblogs.com/chenshuo/p/4743144.html