MySQL client Chinese garbled problem solved

Source: Internet
Author: User
Tags mysql client

Using MySQL Client access on a Linux machine to get Chinese is sometimes garbled, as follows:

Mysql> SELECT *From T_user;+----+-----------+-------------+-------------------+----------------------------------+----------+------------- --------+---------------------+-----------+| ID | User_name | User_phone | User_email | User_pwd | Pwd_salt | Create_time | Modify_time | Is_delete |+----+-----------+-------------+-------------------+----------------------------------+----------+--  -------------------+---------------------+-----------+|       1 |??? | 13285250574 | [Email protected] | 05126a423a9379d529e4ee61a212fa55 | KJUYT5 | 2016-07-15 23:38:56 |         2016-07-15 23:39:09 |  0 | |       2 |??? | 15985250574 | [Email protected] | 98bd3a1bebde01ad363d3c5a0d1e56da | 656JHU | 2016-07-15 23:39:01 |         2016-07-15 23:39:13 |  0 | |       3 |??? | 13685250574 | [Email protected] | 5470DB9B63C354F6C8D628B80AE2F3C3 | 89UIKQ | 2016-07-15 23:39:05 |         2016-07-15 23:39:16 | 0 |+----+-----------+-------------+-------------------+----------------------------------+----------+---------------------+---------------------+-----------+3 rows in Set (0.00 Sec

At this point, look at the MySQL character set and set it to the same character set as the database (table):

Mysql> Select @variable like ' character_set_results '; +----------------------------------------+| @variable like ' character_set_results ' |+----------------------------------------+|                                   NULL |+----------------------------------------+1 row in Set (0.00 sec) MySQL> Set character_set_results= ' UTF8 '0 rows Affected (0.00 sec)

Then, the query will be able to get the normal Chinese characters:

Mysql> SELECT *From T_user;+----+-----------+-------------+-------------------+----------------------------------+----------+------------- --------+---------------------+-----------+| ID | User_name | User_phone | User_email | User_pwd | Pwd_salt | Create_time | Modify_time | Is_delete |+----+-----------+-------------+-------------------+----------------------------------+----------+--  -------------------+---------------------+-----------+| 1 | Zhao Da Bao | 13285250574 | [Email protected] | 05126a423a9379d529e4ee61a212fa55 | KJUYT5 | 2016-07-15 23:38:56 |         2016-07-15 23:39:09 |  0 | | 2 | Zhang Sanfeng | 15985250574 | [Email protected] | 98bd3a1bebde01ad363d3c5a0d1e56da | 656JHU | 2016-07-15 23:39:01 |         2016-07-15 23:39:13 |  0 | | 3 | Wang Nima | 13685250574 | [Email protected] | 5470DB9B63C354F6C8D628B80AE2F3C3 | 89UIKQ | 2016-07-15 23:39:05 |         2016-07-15 23:39:16 | 0 |+----+-----------+-------------+-------------------+----------------------------------+----------+---------------------+---------------------+-----------+3 rows in Set (0.00 sec) 

MySQL client Chinese garbled problem solved

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.