Summary under MySQL Chinese garbled, phpmyadmin garbled, PHP garbled causes and Solutions 1th 3 page

Source: Internet
Author: User
The reason for garbled production
MySQL character encoding is introduced in version 4.1, supports multiple languages, and some features have surpassed other database systems.
We can view the MySQL character set by entering the following command under MySQL command line Client
mysql> SHOW CHARACTER SET;
+----------+-----------------------------+---------------------+--------+
| Charset | Description | Default Collation | MaxLen |
+----------+-----------------------------+---------------------+--------+
| Big5 | Big5 Traditional Chinese | Big5_chinese_ci | 2 |
| Dec8 | DEC West European | Dec8_swedish_ci | 1 |
| cp850 | DOS West European | Cp850_general_ci | 1 |
| HP8 | HP West European | Hp8_english_ci | 1 |
| koi8r | Koi8-r relcom Russian | Koi8r_general_ci | 1 |
| Latin1 | cp1252 West European | Latin1_swedish_ci | 1 |
| latin2 | ISO 8859-2 Central European | Latin2_general_ci | 1 |
| Swe7 | 7bit Swedish | Swe7_swedish_ci | 1 |
| ASCII | US ASCII | Ascii_general_ci | 1 |
| Ujis | EUC-JP Japanese | Ujis_japanese_ci | 3 |
| Sjis | Shift-jis Japanese | Sjis_japanese_ci | 2 |
| Hebrew | ISO 8859-8 Hebrew | Hebrew_general_ci | 1 |
| tis620 | TIS620 Thai | Tis620_thai_ci | 1 |
| Euckr | EUC-KR Korean | Euckr_korean_ci | 2 |
| koi8u | Koi8-u Ukrainian | Koi8u_general_ci | 1 |
| gb2312 | GB2312 Simplified Chinese | Gb2312_chinese_ci | 2 |
| Greek | ISO 8859-7 Greek | Greek_general_ci | 1 |
| cp1250 | Windows Central European | Cp1250_general_ci | 1 |
| GBK | GBK Simplified Chinese | Gbk_chinese_ci | 2 |
| Latin5 | ISO 8859-9 Turkish | Latin5_turkish_ci | 1 |
| Armscii8 | ARMSCII-8 Armenian | Armscii8_general_ci | 1 |
| UTF8 | UTF-8 Unicode | Utf8_general_ci | 3 |
| UCS2 | UCS-2 Unicode | Ucs2_general_ci | 2 |
| cp866 | DOS Russian | Cp866_general_ci | 1 |
| KEYBCS2 | DOS Kamenicky Czech-slovak | Keybcs2_general_ci | 1 |
| Macce | Mac Central European | Macce_general_ci | 1 |
| Macroman | Mac West European | Macroman_general_ci | 1 |
| cp852 | DOS Central European | Cp852_general_ci | 1 |
| latin7 | ISO 8859-13 Baltic | Latin7_general_ci | 1 |
| cp1251 | Windows Cyrillic | Cp1251_general_ci | 1 |
| cp1256 | Windows Arabic | Cp1256_general_ci | 1 |
| cp1257 | Windows Baltic | Cp1257_general_ci | 1 |
| binary | Binary Pseudo CharSet | binary | 1 |
| Geostd8 | GEOSTD8 Georgian | Geostd8_general_ci | 1 |
| cp932 | SJIS for Windows Japanese | Cp932_japanese_ci | 2 |
| Eucjpms | Ujis for Windows Japanese | Eucjpms_japanese_ci | 3 |
+----------+-----------------------------+---------------------+--------+
$ rows in Set (0.02 sec)
For more information on MySQL's character set, refer to this forum
Http://www.phpfans.net/bbs/viewt ... &extra=page%3d1
or the official MySQL
Http://dev.mysql.com/doc/refman/5.1/zh/charset.html
The character set support for MySQL 4.1 (Character set supports) has two aspects: the character set (Character set) and the Sort method (Collation). Support for character sets is refined to four levels: server, database, data table (table), and connection (connection).
The settings for viewing the character set and ordering of the system can be set through the following two commands:
mysql> SHOW VARIABLES like ' character_set_% ';
+--------------------------+-------------------------------------------+
| variable_name | Value |
+--------------------------+-------------------------------------------+
| character_set_client | Latin1 |
| character_set_connection | Latin1 |
| Character_set_database | Latin1 |
| Character_set_filesystem | binary |
| Character_set_results | Latin1 |
| Character_set_server | Latin1 |
| Character_set_system | UTF8 |
| Character_sets_dir | D:\MySQL\MySQL Server 5.0\share\charsets\ |
+--------------------------+-------------------------------------------+
8 rows in Set (0.06 sec)
mysql> SHOW VARIABLES like ' collation_% ';
+----------------------+-------------------+
| variable_name | Value |
+----------------------+-------------------+
| collation_connection | Latin1_swedish_ci |
| Collation_database | Latin1_swedish_ci |
| Collation_server | Latin1_swedish_ci |
+----------------------+-------------------+
3 Rows in Set (0.02 sec)
The values listed above are the default values for the system. Latin1 default proofing rules are latin1_swedish_ci, which by default is the Swedish sort method for Latin1.
The default is Latin1_swedish_ci, so it's easy to trace the history of MySQL.
In 1979, a Swedish company TCX to develop a fast multi-threaded, multiuser database system. TCX Company initially wanted to use mSQL and their own fast low-level routines (Indexed sequential Access Method,isam) to connect to the database tables, however, after some tests concluded that mSQL was not fast and flexible enough for its needs. This creates a new SQL interface for the connector database that uses almost the same API interface as mSQL. This API is designed to make it easier to migrate third-party code written by mSQL to MySQL.
I believe that if MySQL is developed in China, then Chinese is the default encoding
Of course we can also need to modify the default character set of MySQL
In MySQL configuration document My.ini, find the following two sentences:
[MySQL]
Default-character-set=latin1
And
# created and no character set is defined
Default-character-set=latin1
You can modify the values that follow.
Changes are not recommended here, and the default values remain
This means that when you start MySQL, if you do not specify a default character set, the value inherits from the configuration file;
At this point the character_set_server is set to the default character set, and when a new database is created,
Unless explicitly specified, the character set of this database is set to Character_set_server by default, and when a database is selected,
Character_set_database is set to the default character set for this database, and when a table is created in this database,
The default character set of the table is set to Character_set_database, which is the default character set of the database;
When a column is set within a table, the default character set for this column is the table's character set, unless explicitly specified.
So the problem comes, if a database is GBK encoded. If the database is accessed without specifying its character set, it is GBK.
Then this value will inherit the system's latin1, so that the MySQL Chinese garbled.
Garbled resolution method
In order to solve the garbled problem, we must first understand what code the database uses. If not specified, it will be the default latin1.
The most we should use is the 3 character set Gb2312,gbk,utf8.
So how do we go about specifying the character set of the database? Below also GBK for example
"CREATE database in MySQL Command line client"
mysql> CREATE TABLE ' Mysqlcode ' (
' ID ' TINYINT (255) UNSIGNED not NULL auto_increment PRIMARY KEY,
' Content ' VARCHAR (255) Not NULL
) TYPE = MYISAM CHARACTER SET gbk COLLATE gbk_chinese_ci;
Query OK, 0 rows affected, 1 warning (0.03 sec)

Current 1/3 page 123 next page

The above describes the summary under the MySQL Chinese garbled, phpmyadmin garbled, PHP garbled causes and Solutions 1th 3 pages, including the content, I hope to be interested in the PHP tutorial friends helpful.

  • 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.