. Net MySQL Chinese garbled Solution

Source: Internet
Author: User

1) as long as it is gb2312, GBK, utf8, and other character sets that support multi-byte encoding, you can store Chinese characters. Of course, the number of Chinese Characters in gb2312 is much smaller than that in GBK, while in gb2312, GBK and so on can all 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 I 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; you can also set all character sets of the client at one time.

In. NET and MySQL databases, I also encountered a situation where Chinese characters could not be displayed!

My solution is to add a character set charset = utf8 to the connection character;

 

<Deleetask>

<Add key = "conn" value = "Server = 127.0.0.1; userid = root; Password = test; database = game; Port = 3306; charset = utf8;"/>

</Appsettings>

 

If UTF-8 encoding is used in Python

When creating data, you must add the default Character Set utf8 collate utf8_general_ci

Otherwise, a message such as data too long for column is displayed when you enter Chinese characters!

Create Database test default Character Set utf8 collate utf8_general_ci

 

 

MySQL authorized remote host:

Grant all privileges on *. * to identified by 'mypassword' with grant option;

 

If you want to allow myuser to connect to the MySQL server from a host whose IP address is 192.168.1.3, and use mypassword as the password:

Grant all privileges on *. * to identified by 'mypassword' with grant option;

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.