码迷,mamicode.com
首页 > 数据库 > 详细

Mysql不乱码思维流程

时间:2016-06-21 21:07:25      阅读:234      评论:0      收藏:0      [点我收藏+]

标签:database   linux   server   names   

>不乱码思维流程

(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; 



Mysql不乱码思维流程

标签:database   linux   server   names   

原文地址:http://2143754.blog.51cto.com/2133754/1791326

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!