How to solve Chinese garbled characters in MySql and php

Source: Internet
Author: User

I. gb2312, gbk, utf8, and other character sets supporting multi-byte encoding can store Chinese characters. The number of Chinese Characters in gb2312 is much smaller than that in gb2312, while that in gb2312 and gbk can be encoded in utf8.

2. Run the show variables like 'character \ _ set \ _ % 'command to view the current character set settings:

Mysql> show variables like 'character \ _ set \ _ % ';

+ -------------------------- + -------- +

| Variable_name | Value |

+ -------------------------- + -------- +

| Character_set_client | gb2312 |

| Character_set_connection | gb2312 |

| Character_set_database | gb2312 |

| Character_set_filesystem | binary |

| Character_set_results | gb2312 |

| Character_set_server | latin1 |

| Character_set_system | utf8 |

+ -------------------------- + -------- +

7 rows in set (0.02 sec)

(The character set here is gb2312)

There are two main settings for displaying Chinese garbled characters: character_set_connection and character_set_results,

If your two settings do not support Chinese encoding, garbled characters will appear. If: set character_set_results = gbk;, the Chinese encoding will be set.

3. set names charset_name; all character sets of the client can be set at one time.

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.