MySQL Client data garbled problem

Source: Internet
Author: User
Tags mysql client

When inserting Chinese data into MySQL, there is garbled, as follows:

Mysql> select * from test;
+------+-----------+
| ID | name |
+------+-----------+
| 1 | Phenomena example belong 鍧? |
| 2 | Phenomena phone 檽 traitor? |
| 3 | Lao à size Boss? |
| 4 | Phenomena 嬮 vent traitor? |
| 5 | ACI 嗕 簯 |
| 6 | Jean Taiwan Upsome Lian? |
| 1 | Demo1 |
| 2 | Demo2 |
| 3 | Demo3 |
+------+-----------+

But in the application, it can be a normal reality data

1 Li Xiaofeng
2 Wang Xiaofeng
3 Photos of snow
4 Wang Xuefeng
5 Lu Yun
6 Peach Blossom Girl
1demo1
2demo2
3demo3

In order for the client to display the Chinese correctly, the following encoding set can be modified, as follows:

Enter show variables like ' char% ';

Mysql> Show variables like ' char% ';
+--------------------------+-----------------------------+
| variable_name | Value |
+--------------------------+-----------------------------+
| character_set_client | UTF8 |
| character_set_connection | GBK |
| Character_set_database | GBK |
| Character_set_filesystem | binary |
| Character_set_results | UTF8 |
| Character_set_server | GBK |
| Character_set_system | UTF8 |
| Character_sets_dir | D:\mysql6.0\share\charsets\ |
+--------------------------+-----------------------------+
8 rows in Set (0.00 sec)

You can see that both the Character_set_client and character_set_results codes are UTF8 and now change them to GBK

Mysql> set CHARACTER_SET_CLIENT=GBK;
Query OK, 0 rows Affected (0.00 sec)


Mysql> set CHARACTER_SET_RESULTS=GBK;
Query OK, 0 rows Affected (0.00 sec)

Then use show variables like ' char% '; query

Mysql> Show variables like ' char% ';
+--------------------------+-----------------------------+
| variable_name | Value |
+--------------------------+-----------------------------+
| character_set_client | GBK |
| character_set_connection | GBK |
| Character_set_database | GBK |
| Character_set_filesystem | binary |
| Character_set_results | GBK |
| Character_set_server | GBK |
| Character_set_system | UTF8 |
| Character_sets_dir | D:\mysql6.0\share\charsets\ |
+--------------------------+-----------------------------+

View the contents of the database again

Mysql> select * from test;
+------+--------+
| ID | name |
+------+--------+
| 1 | Li Xiaofeng |
| 2 | Wang Xiaofeng |
| 3 | Zhangxiaoxue |
| 4 | Wang Xuefeng |
| 5 | Lu Yun |
| 6 | Peach Blossom Women |
| 1 | Demo1 |
| 2 | Demo2 |
| 3 | Demo3 |
+------+--------+
9 Rows in Set (0.00 sec)

MySQL Client data garbled problem

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.