Detailed explanation of MYSQL character set setting method (terminal character set)

Detailed explanation of MYSQL character set setting method (terminal character set)

Preface

Every time I use the terminal to create a database or table, the character set is latin1, or when inserting values, garbled characters are displayed (when the character set is not specified) as follows:

View the character set of the current database

character_set_client: The character set of the client request data

character_set_connection: Character set for client/server connections

character_set_database: The character set of the default database. This character set is used regardless of how the default database is changed. If there is no default database, the character set specified by character_set_server is used. It is recommended that this variable be managed by the system itself and not defined manually.

character_set_filesystem: Convert the file name on the OS to this character set, that is, convert character_set_client to character_set_filesystem. The default binary does not perform any conversion.

character_set_results: result set, character set returned to the client

character_set_server: The default character set of the database server

character_set_system: System character set. This value is always utf8 and does not need to be set. This character set is used for the names of database objects (such as tables and columns), and also for the names of functions stored in catalog tables.

View the collation rules of the current database

show variables like 'collation%';

In the parameter file, the utf8mb4 character set is set in client, mysql, and mysqld, but the collation related parameters are not set

collation_connection The character set of the current connection.

collation_database The default collation for the current date. The value of this variable changes every time you use the USE statement to "jump" to another database. If there is no current database, the value of this variable is the value of the collation_server variable.

collation_server The default collation for the server.

The naming rule of the sorting method is: character set name_language_suffix, where the meanings of each typical suffix are as follows:

1) _ci: case-insensitive sorting

2) _cs: case-sensitive sorting

3) _bin: Binary sorting method. The size comparison will be based on the character encoding and does not involve human language. Therefore, the sorting method of _bin does not include human language.
create database rommel default charset utf8 collate utf8_romanian_ci;

Add the following to the parameter file [mysqld]

[mysqld]
character-set-server=utf8mb4
collation-server=utf8mb4_general_ci

Perform a test after restarting the database.

After a series of tests, the modification was successful.

Therefore, during installation, parameters must be modified. It is impossible to compile the database after installation. If the database cannot be restarted during production, in addition to creating each table and hard-coding the database, you can only temporarily specify the character set.

Temporary designation:

SET character_set_client = utf8mb4;

SET character_set_connection = utf8mb4;

SET character_set_database = utf8mb4;

SET character_set_results = utf8mb4;

SET character_set_server = utf8mb4;

Summarize

This is the end of this article about MYSQL character set settings (terminal character set). For more relevant MYSQL character set settings (terminal character set) content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • In-depth analysis of Mysql character set settings
  • mysql odbc character set setting (Chinese characters are displayed in garbled characters)
  • In-depth Mysql character set settings [Essence combination]
  • Mysql default character set setting method (free installation version)
  • Regarding the MySQL character set, character_set_client=binary is set. In the case of GBK, the table description will be garbled.
  • In-depth MySQL character set settings graphic version
  • How to set the character set for mysql under Docker
  • Take you to understand MySQL character set settings in 5 minutes
  • Detailed explanation of character set settings based on MySQL 5.5
  • mysql commonly used settings character set encoding, auto-completion (auto prompt), monitor external network ip

<<:  A brief discussion on the role of the docker --privileged=true parameter

>>:  XHTML Getting Started Tutorial: XHTML Hyperlinks

Recommend

React non-parent-child component parameter passing example code

React is a JAVASCRIPT library for building user i...

nginx+tomcat example of accessing the project through the domain name

I was curious about how to access the project usi...

Workerman writes the example code of mysql connection pool

First of all, you need to understand why you use ...

Implementation of Nginx forwarding matching rules

1. Regular expression matching ~ for case-sensiti...

Detailed explanation of screen command usage in Linux

GUN Screen: Official website: http://www.gnu.org/...

40 CSS/JS style and functional technical processing

1- Styling dropdown select boxes - Modify the dro...

JavaScript implements simple date effects

The specific code of JavaScript date effects is f...

Virtual Box tutorial diagram of duplicating virtual machines

After getting used to VM, switching to BOX is a l...

HTML n ways to achieve alternate color code sample code

This article mainly introduces the sample code of...

Markup Language - Title

Click here to return to the 123WORDPRESS.COM HTML ...

A simple example of how to implement fuzzy query in Vue

Preface The so-called fuzzy query is to provide q...

jQuery achieves the effect of advertisement scrolling up and down

This article shares the specific code of jQuery t...

In-depth analysis of the slow query problem of MySQL Sending data

Through an example, I shared with you the solutio...