>不乱码思维流程
(1)Linux
#修改linux系统字符集
# vi /etc/sysconfig/i18n
LANG="zh_CN.UTF-8"
(2)Mysql
#临时设置字符集(方法一)
mysql> set names utf8;
#临时设置字符集(方法二)
# mysql -uroot -p --default-character-set=utf8
#永久设置字符集
# vi /etc/my.cnf
[client]{client ,connection,results}
default-character-set=utf8
[mysqld]{database,server}
default-character-set=utf8
mysql> show variables like ‘character_set%‘;
+--------------------------+-------------------------------------------+
| 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 | /application/mysql-5.5.32/share/charsets/ |
+--------------------------+-------------------------------------------+
(3)Mysql 库表
#创建指定字符集数据库
mysql> create database oldboy_gbk DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;