Xampp Mysql garbled

Source: Internet
Author: User

Read a lot of articles, most just talk about how to operate, do not involve the principle, is very disappointed, like headless flies as a random collision.

First look at the character sets involved in the Php+mysql+apache environment:

Describes the database internal storage character set:

The "database internal storage Character Set" refers to what encoding the data is stored in the database. Includes three types of granular character sets: Server character set, database character set, and database table character set. The priority of these three sets of characters is higher, and the database table character set has precedence over the database character set larger than the server character set.

Character_set_server/default_character_setrefers to the server character set;Character_set_databaserefers to the database character set;character_set_tablerefers to the database table character set.

Describes the client-side request character set and the request result character set:

Character_set_client: The character set of the client. The client default character set. When a client sends a request to the server, the request is encoded in that character set.

Character_set_results: Result character Set. When the server returns a result or information to the client, the result is encoded in that character set.

On the client, if Character_set_results is not defined, the Character_set_client character set is used as the default character set. So only the character_set_client character set is required.

Character_set_connection

  The character set used for literals and does not has a character set introducer and for number-to-string conversion.

MySQL Character set conversion process:

SET NAMES ' charset_name ' [COLLATE ' collation_name ']:

Add: mysql_query ("SET NAMES UTF8") in the PHP code;

Reference documents:

Http://www.laruence.com/2008/01/05/12.html

Http://dev.mysql.com/doc/refman/5.5/en/charset.html

Http://jingyan.baidu.com/article/48a42057c069d7a9242504fb.html

http://m.blog.csdn.net/blog/zexin1000/7956935

Xampp Mysql garbled

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.