Analysis of MySQL Character Set and garbled characters

Source: Internet
Author: User

There are many types of MySQL character sets that affect programming, mainly client character sets and database character sets.

Common Operations in databases are to save data and read data. In this process, there seems to be nothing to do with the MySQL character set. We only need to ensure that the character set selected during the write operation is consistent with the character set selected during the read operation, that is, we only need to ensure that the client MySQL character set for the two operations is consistent.

The client Character Set settings are different based on different client methods:

1. Use the console to connect and set it in the client item in the my. ini file;

2. Use EMS to connect. Use EMS to connect to the configured Character Set first. The settings in my. ini file are used by default;

3. For jdbc connection, specify the following in the connection string:

 
 
  1. jdbc:mysql://192.168.3.99:3306/test?useUnicode=true& ;characterEncoding=gbk 

During writing, Mysq converts the character set specified by the client to the database character set and saves it to the data file. During reading, the database character set is converted to the character set specified by the client and displayed to the client, setting the client character set is the same as that of the database. The obvious benefit is that the conversion performance is free of consumption. In addition, if you consider the future database migration, setting the database character set to the character set supported by most databases saves a lot of trouble.

Several Character Set-related commands:

1. View MySQL database server Character Set, database character set, and client Character Set

 
 
  1. show variables like '%char%'; 

◆ Character_set_client, client Character Set

◆ Character_set_database, database Character Set

◆ Character_set_server, server Character Set

2. view the MySQL Character Set Data table)

 
 
  1. show table status from tablename like '%countries%';   

3. view the data column (column) of the MySQL character set ).

 
 
  1. show full columns from tablename;   

4. view the character sets supported by currently installed MySQL.

  1. Thoughts on MySQL character set architecture
  2. Introduction to MySQL Character Set
  3. How to lock MySQL database tables
  4. How to fix MySQL database tables
  5. Test the replication feature of New MySQL features (1)

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.