The following articles mainly introduce the basic types of MySQL character sets, The actual operating method of the unified character set and other related content are described as follows.
I. MySQL Character Set Type
MySQL servers use character sets in six key locations: client, connection, database, results, server, and system.
A. The client is the character set used by the client. It is equivalent to setting the character set in the webpage as follows <meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8">.
B. The connection is the MySQL Character Set setting type for connecting to the database. If php does not specify the character set type used for connecting to the database, it is set according to the default character set on the server.
C. database is the character set used by a database in the database server. If it is not specified during database creation, the character set specified during Server installation will be used.
D. results is the MySQL character set used by the database to return data to the client. If not specified, use the default Character Set of the server.
E. server is the default character set specified during server installation.
F and system are character set used by the database system.
PS:
1. system is generally the UTF-8 character set by default, and server is the highest character set. databases are set according to the character set of server if they are not set separately. Others are set according to server settings.
2. each table and field in the database also has the character set concept. Generally, the character set is determined based on the upper-level structure. For example, the table determines its character set according to the database settings, the field determines its character set based on the table.
Ii. Methods for unified character sets: Installation using the UTF-8 character set)
1. The complete solution to the character set is to enable MySQL to use the UTF-8 character set during installation (latin1 by default), so that the encoding of the preceding six key points is UTF-8.
2. Run the STATUS command to view the STATUS of various character sets in MySQL.
You can also use show variables like 'character _ set _ % 'to view some settings of the MySQL character set.
3. If MySQL sets the character set to latin1 during installation
You can specify the utf8 character set when creating a database.
- CREATE DATABASE qss DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
The above content is a summary of the MySQL character set. I hope you will get something.
The above content is a summary of the MySQL Character Set, hoping to help you in this regard.