Introduction to transcoding in mysql command line cmd Environment

Source: Internet
Author: User

I believe you have some knowledge about mysql command line. The following describes how to convert the code in the mysql command line cmd environment for your reference.

Everyone knows
Set names x
Equivalent
SET character_set_client = x;
SET character_set_results = x;
SET character_set_connection = x;

The following documents extract related content from the official MySQL5.0 documents and translate them to illustrate the usefulness of related system variables:

What character set is the statement in when it leaves the client?
What character set is statement when it leaves the client?

The server takes the character_set_client system variable to be the character set in which statements are sent by the client.
The statement sent by the client. The server considers its character set as the value of the character_set_client system variable.

What character set shocould the server translate a statement to after loading it?
What character set does the server convert a statement?

For this, the server uses the character_set_connection and collation_connection system variables. it converts statements sent by the client from character_set_client to character_set_connection (Response t for string literals that have an introducer such as _ latin1 or _ utf8 ). collation_connection is important for comparisons of literal strings. for comparisons of strings with column values, collation_connection does not matter because columns have their own collation, which has a higher collation precedence.
For this purpose, the server uses the system variables character_set_connection and collation_connection. It converts the statement sent from the client from the character_set_client character set to the character_set_connection Character Set unless the string contains a character set declaration similar to _ latin1 or _ utf8 ). Collation_connection is very important for string comparison. Collation_connection does not work for comparing character-type field values. Because the field has its own collation, it has a higher priority.

What character set shocould the server translate to before shipping result sets or error messages back to the client?
What character set does the result set need to be converted to before it is passed to the client by the server?

The character_set_results system variable indicates the character set in which the server returns query results to the client. This includes des result data such as column values, and result metadata such as column names.
The character_set_results system variable indicates the character set used by the server to return the query results. The returned data includes field values and metadata such as field names ).

If you are using the mysql client with auto-reconnect enabled (which is not recommended), it is preferable to use the charset command rather than set names. For example:
If you use the mysql client for automatic reconnection, we recommend that you use the charset command instead of set names. For example:

Mysql> charset utf8
Charset changed

The charset command issues a set names statement, and also changes the default character set that is used if mysql reconnects after the connection has dropped.
The charset command issues a set names statement, and the default character SET used for automatic reconnection after the connection is disconnected is also modified.

The database character set and collation are used as default values if the table character set and collation are not specified in create table statements. They have no other purpose.
If the character set and collation are not explicitly specified in the create table, the database character set and collation are used as default values, and they are of no other use.

The character set and collation for the default database can be determined from the values of the character_set_database and collation_database system variables. the server sets these variables whenever the default database changes. if there is no default database, the variables have the same value as the corresponding server-level system variables, character_set_server and collation_server.
The character set and collation of the default database can be viewed through the system variables character_set_database and collation_database. When the default database changes, the server sets the value of these variables. If no default database exists, these variables will have the same value as the corresponding server-level system variables-character_set_server and collation_server.

The table character set and collation are used as default values if the column character set and collation are not specified in individual column definitions. the table character set and collation are MySQL extensions; there are no such things in standard SQL.
The character set and collation of the table are used as the default values if the character set and collation are not specified in the column definition.

Every "character" column (that is, a column of type CHAR, VARCHAR, or TEXT) has a column character set and a column collation.
Each "character" field is a CHAR, VARCHAR, or TEXT field) has a field character set and field validation collation ).

Every character string literal has a character set and a collation.
Each string has a character set and a comparison.

A character string literal may have an optional character set introducer and COLLATE clause:
Each string has an optional character set introducer and COLLATE clause:

[_ Charset_name] 'string' [COLLATE collation_name]

Examples:

SELECT 'string ';
SELECT _ latin1 'string ';
SELECT _ latin1 'string' COLLATE latin1_danish_ci;

Troubleshooting of MySQL command line garbled

10 common MySQL command lines

Seven common MySQL command lines

Use the MySQL command line to change the password

MySQL command line Common commands

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.