MySQL coding, MySQL coding process, MySQL coding sequence, MySQL coding principle, MySQL code modification basis

Source: Internet
Author: User

code viewing method and Explanation:You need to log in as root to see how the database is encoded (the command logged in as root: >mysql-u root–p, then two times the root user's password), to view the database encoding command: >show variables Like ' character% '; +--------------------------+----------------------------+| 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 | /usr/share/mysql/charsets/|+--------------------------+----------------------------+ from the above information, the database encoding is latin1, Need to be modified to GBK or UTF8, where Character_set_client: encoding the client, the character set used in the query sent by the client character_set_connection: encoding used for establishing the connection; character_ Set_database: The encoding of the database, the character set set used by a library in the database server, and the character set settings specified when the server was installed if it was not specified when the library was built. Character_set_results: Encoding of the result set;to be verified: as long as the above to ensure that the same encoding method, there will be no garbled problem. Character_set_server: The encoding of the database server; The default character set specified when the server is installed. Character_system: The character set used by the database system. Another command to view the database encoding: >show VARIABLES like ' collation% '; MySQL storage principles for character encoding program configuration file. Connection string: Charset=utf8, Description:Query statements are sent to the server using this encoding format NOTE: The query results are still delivered in the format of the reverse data. Query Statement execution logic:1. Program Configuration connection string: Charset=utf8, the query statement using "Charset=utf8" encoding of this format is sent to the server 2. MySQL converts the received query statement into the format specified by Character_set_client, 3. Then turn to character_set_connection specified format 4. The character_set_connection is then converted to an internal manipulation character-using the CHARACTER set setpoint for each data field-if the above value does not exist, the default CHARACTER set SetPoint of the corresponding data table is used (M Ysql extension, non-SQL standard);-If the above value does not exist, the default CHARACTER set value of the corresponding database is used;-if the above value does not exist, use the Character_set_server setpoint. 5. Convert the operation result from the internal operation character set to Character_set_results. executing the statement execution logic1. Program Configuration connection string: Charset=utf8, the execution statement using "Charset=utf8" encoding of this format is sent to the server 2. MySQL converts the received query statement into the format specified by Character_set_client, 3. Then turn to character_set_connection specified format 4. Then convert character_set_connection to internal action character        -use character set setpoint for each data field;       - If the above value does not exist, the default CHARACTER set value of the corresponding data table (MySQL extension, non-SQL standard);       -If the above value does not exist, the default of the corresponding database is used CHARACTER set setpoint;       -If the above values do not exist, use the Character_set_server setpoint. 5. Convert the operation result from the internal operation character set to character_set_database storage  

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.