Linux系统修改mysql默认编码:
首先查看现在的编码show variables like ‘character%’;
结果如下:
mysql> show variables like 'character%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | latin1 |
| character_set_connection | latin1 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | latin1 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
当然如果里面是utf8的话就不用改了…
有三个地方需要动的
[client]下面加上
default-character-set=utf8
[mysqld]下面加上
default-character-set=utf8
init_connect='SET NAMES utf8'
然后再看一下变量
+--------------------------+----------------------------+
| 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/ |
+--------------------------+----------------------------+
可以看一下手册关于系统变量的部分. 有的配置在配置文件和使用show variables都看不到.但是可以设置
如果是windows可以直接使用Mysql Server Instance Config Wizard配置。
--转自