mysql> use demodb;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql>
mysql> show variables like 'character\_set\_%';
+--------------------------+--------+
| 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 |
+--------------------------+--------+
7 rows in set (0.00 sec)
mysql> set character_set_client=utf8;
Query OK, 0 rows affected (0.01 sec)
mysql> show variables like 'character\_set\_%';
+--------------------------+--------+
| Variable_name | Value |
+--------------------------+--------+
| character_set_client | utf8 |
| character_set_connection | latin1 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | latin1 |
| character_set_server | latin1 |
| character_set_system | utf8 |
+--------------------------+--------+
7 rows in set (0.00 sec)
mysql> select * from project;
+-------+------------+------+--------------+-------------+-----------+----------+--------------+--------+
| ID | pname | URL | LEAD | DESCRIPTION | pkey | pcounter | ASSIGNEETYPE | AVATAR |
+-------+------------+------+--------------+-------------+-----------+----------+--------------+--------+
| 10200 | demo | NULL | aaa | NULL | DEMO | 159 | 2 | 10011 |
| 10300 | demo2 | NULL | bbb | NULL | DEMOTWO | 1 | 2 | 10011 |
| 10302 | ?????? | | ccc | | FFF | 0 | 2 | 10011 |
| 10500 | ???? | NULL | aaa | NULL | QQQ | 11 | 2 | 10011 |
| 10501 | SCRUM-???? | NULL | ddd | NULL | SFFF | 24 | 2 | 10011 |
| 10502 | ?????? | NULL | eee | NULL | SSS | 6 | 2 | 10011 |
| 10504 | ???? | NULL | fff | NULL | FINANCING | 2 | 2 | 10011 |
+-------+------------+------+--------------+-------------+-----------+----------+--------------+--------+
7 rows in set (0.00 sec)
mysql>
mysql> set character_set_connection=utf8;
Query OK, 0 rows affected (0.00 sec)
mysql> set character_set_database=utf8;
Query OK, 0 rows affected (0.00 sec)
mysql> set character_set_results=utf8;
Query OK, 0 rows affected (0.00 sec)
mysql> set character_set_server=utf8;
Query OK, 0 rows affected (0.00 sec)
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 |
+--------------------------+--------+
7 rows in set (0.00 sec)
mysql> select * from project;
+-------+--------------------+------+--------------+-------------+-----------+----------+--------------+--------+
| ID | pname | URL | LEAD | DESCRIPTION | pkey | pcounter | ASSIGNEETYPE | AVATAR |
+-------+--------------------+------+--------------+-------------+-----------+----------+--------------+--------+
| 10200 | demo | NULL | aaa | NULL | DEMO | 159 | 2 | 10011 |
| 10300 | demo2 | NULL | bbb | NULL | DEMOTWO | 1 | 2 | 10011 |
| 10302 | 實例項目需求 | | ccc | | FFF | 0 | 2 | 10011 |
| 10500 | 演示項目 | NULL | ddd | NULL | QQQ | 11 | 2 | 10011 |
| 10501 | SCRUM-實例項目 | NULL | eee | NULL | SFFF | 24 | 2 | 10011 |
| 10502 | 正式A需求 | NULL | fff | NULL | SSS | 6 | 2 | 10011 |
| 10504 | 正式T | NULL | ddd | NULL | FINANCING | 2 | 2 | 10011 |
+-------+--------------------+------+--------------+-------------+-----------+----------+--------------+--------+
7 rows in set (0.00 sec)
通過以上過程說明.僅僅通過set character_set_client=utf8;是不能解決亂碼問題的.解決亂碼問題需要把mysql的服務(wù)器編碼設(shè)置成utf8,同時,創(chuàng)建數(shù)據(jù)庫的時候需要把數(shù)據(jù)庫的編碼設(shè)置成utf8編碼,才能解決mysql數(shù)據(jù)庫查詢亂碼問題.
如果數(shù)據(jù)庫服務(wù)器的編碼是utf8,而數(shù)據(jù)庫的編碼也是utf8,在客戶端查詢出現(xiàn)亂碼,基本上可以推斷是客戶端的設(shè)置不是utf8編碼.
數(shù)據(jù)庫服務(wù)編碼設(shè)置請參見mysql服務(wù)端編碼設(shè)置.
|----------------------------------------------------------------------------------------|
版權(quán)聲明 版權(quán)所有 @zhyiwww
引用請注明來源 http://www.aygfsteel.com/zhyiwww
|----------------------------------------------------------------------------------------|