ubuntu 下mysql中文乱码问题解决方案

mysql> show variables like 'character%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set

mysql>
mysql>
mysql>
mysql> set character_set_server=utf8;
Query OK, 0 rows affected

mysql>
mysql>
mysql> set character_set_database=utf8;
Query OK, 0 rows affected

mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql> select * from user;
+----+----------+----------+-----------+---------+------------+
| id | username | password | user_role | isAdmin | user_state |
+----+----------+----------+-----------+---------+------------+
| 1 | JAVA | 11111  | 0 | 1 | 0 |
| 2 | Php | 11111  | 2 | 2 | 1 |
| 3 | Python | 11111  | 2 | 2 | 1 |
+----+----------+----------+-----------+---------+------------+
10 rows in set

mysql>
mysql>
mysql> 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/ |
+--------------------------+----------------------------+

posted @ 2015-12-03 16:44  西北逍遥  阅读(317)  评论(0编辑  收藏  举报