日期:2014-05-16  浏览次数:21070 次

ubuntu 12.04 mysql 编码问题

1. 修改/etc/mysql/my.conf

[mysqld]

character-set-server=utf8

?

重启报错

start: Job failed to start

?

2.修改[mysqld]

[mysqld]?

init_connect='SET collation_connection = utf8_unicode_ci'?
init_connect='SET NAMES utf8'?
character-set-server=utf8?
collation-server=utf8_unicode_ci?
skip-character-set-client-handshake

?

service mysql restart

?

启动ok

?

3.查看

mysql> show variables like "%character%";show variables like "%collation%";

+--------------------------+----------------------------+
| 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/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)

+----------------------+-----------------+
| Variable_name??????? | Value?????????? |
+----------------------+-----------------+
| collation_connection | utf8_unicode_ci |
| collation_database?? | utf8_unicode_ci |
| collation_server???? | utf8_unicode_ci |
+----------------------+-----------------+
3 rows in set (0.00 sec)