I believe everyone knows about the default Character Set of MySQL. The following describes the commands for viewing the default Character Set of MySQL. It is helpful to learn about the default Character Set of MySQL.
MySQL Character Set Support has two aspects:
Character set and Collation ).
The support for character sets is refined to four layers:
Server, database, table, and connection ).
1. Default MySQL Character Set
MySQL can refine the character set designation to a database, a table, and a column.
However, traditional programs do not use such complex configurations when creating databases and data tables. They use the default configuration. So where does the default configuration come from?
(1) When compiling MySQL, a MySQL Default character set is specified, which is latin1;
(2) When installing MySQL, you can specify a default character set in the configuration file (my. ini). If this character set is not specified, this value inherits from the one specified during compilation;
(3) When mysqld is started, you can specify a default character set in the command line parameters. If not, this value inherits from the configuration in the configuration file, character_set_server is set to the default character set;
(4) When creating a new database, unless explicitly specified, the character set of this database is set to character_set_server by default;
(5) When a database is selected, character_set_database is set to the default Character Set of the database;
(6) When creating a table in the database, the default Character Set of the table is set to character_set_database, which is the default Character Set of the database;
(7) When setting a column in a table, unless explicitly specified, the default character set in this column is the default Character Set of the table;
Simply put, if you do not modify anything, all the columns of all tables in all databases will be stored in latin1. However, if you install MySQL, you will generally choose multi-language support, that is, the installer automatically sets default_character_set in the configuration file as a UTF-8, which ensures that all columns of all tables in all databases are stored in UTF-8 by default.
2. view the default MySQL character set (by default, the mysql character set is latin1 (ISO_8859_1)
Generally, you can run the following two commands to view the character set and sorting method of the system:
- mysql> 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 | D:"mysql-5.0.37"share"charsets" |
- +--------------------------+---------------------------------+
-
- mysql> SHOW VARIABLES LIKE 'collation_%';
- +----------------------+-----------------+
- | Variable_name | Value |
- +----------------------+-----------------+
- | collation_connection | utf8_general_ci |
- | collation_database | utf8_general_ci |
- | collation_server | utf8_general_ci |
- +----------------------+-----------------+
-
How does MySQL Delete foreign key definitions?
MySQL foreign key syntax
MySql stored procedure with Parameters
Statements used to obtain MySQL table information
How to use mysql UPDATE statements