Solution to the problem that MySQL commands cannot be entered in Chinese

Solution to the problem that MySQL commands cannot be entered in Chinese

Find the problem

Recently, when I connected to the MySQL server through the MySQL command, I was unable to input Chinese characters, as shown below:

mysql> SELECT 'Chinese characters <> are stripped';
+------------------------------------+
| Chinese characters <> are stripped |
+------------------------------------+
| Chinese characters <> are stripped |
+------------------------------------+
1 row in set (0.00 sec)

All Chinese characters entered will be replaced with blanks. The above test is for the official mysql-5.7.32 version.

After going through the official mysql changelog-5.7.34, I found that Oracle's official mysql-5.7.34 and mysql-8.0.24 fixed the following bugs respectively.

For builds compiled using the libedit library, if the mysql client was invoked
With the --default-character-set=utf8 option, libedit rejected input of
multibyte characters. (Bug #32329078, Bug #32583436, Bug #102806)

Refer to bug-102806, which shows a similar problem as described above. The interactive mode of the mysql command line does not support input of all wide characters.

What will happen if I cannot input Chinese?

From the test, this bug only affects the session operation of connecting to MySQL server in interactive mode through mysql command. If there is a version online using this bug, the problem of losing Chinese characters may occur when operating the table.

The following methods are not affected:

1. Each program connects to the database through relevant drivers;
2. The mysql command is operated in non-interactive mode, such as mysql -h ... -p.... < /tmp/t.sql

Which versions are affected?

This bug was fixed in 5.7.34 and 8.0.24, see github-mysql-patch-117fb2. From the patch, the bug has nothing to do with the libedit version, whether it is rpm, deb or official build version.

From our testing, the following versions are affected:

5.7.31 ~ 5.7.33
8.0.21 ~ 8.0.23

Note: Other releases are not clear yet, and there is a high probability that the same problem will occur. However, releases are usually a step behind the official ones, and their lower versions may fix the problem in advance.

How to deal with it

The selection of online versions can focus on some versions that have been used, such as the ones I often use:

- percona branch percona-5.6.45
percona-5.7.28
percona-8.0.22

- Official version mysql-5.6.29
mysql-5.7.28
mysql-8.0.19

If the affected versions are already in use online, you can use the following methods to handle it:

Temporary treatment

If it is not convenient to upgrade, you can first use the mysql client command below 5.7.30 or 5.7.34 and above;

Minor version upgrade

If it is convenient to upgrade a minor version, it is recommended to upgrade to the following version:

5.7.35
8.0.26

Summarize

This is the end of this article about the problem that MySQL commands cannot be input into Chinese. For more related content about MySQL commands cannot be input into Chinese, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Detailed explanation of encoding issues during MySQL command line operations
  • Introduction to the use of MySQL source command
  • MySQL commonly used SQL and commands from entry to deleting database and running away
  • Implementation of mysql using mysqlbinlog command to restore accidentally deleted data
  • Introduction to query commands for MySQL stored procedures
  • Three methods of automatically completing commands in MySQL database
  • MySQL password contains special characters & operation of logging in from command line
  • Mysql desktop tool SQLyog resources and activation methods say goodbye to the black and white command line
  • MySQL login and exit command format
  • How to use the MySQL authorization command grant
  • Summary of MySQL basic common commands

<<:  6 Ways to Elegantly Handle Objects in JavaScript

>>:  Detailed explanation of Docker working mode and principle

Recommend

MySQL concurrency control principle knowledge points

Mysql is a mainstream open source relational data...

How are spaces represented in HTML (what do they mean)?

In web development, you often encounter characters...

5 Easy Ways to Free Up Space on Ubuntu

Preface Most people will probably perform this op...

Use of Linux usermod command

1. Command Introduction The usermod (user modify)...

Html to achieve dynamic display of color blocks report effect (example code)

Use HTML color blocks to dynamically display data...

How to use anti-shake and throttling in Vue

Table of contents Preface concept Stabilization d...

What is MIME TYPE? MIME-Types type collection

What is MIME TYPE? 1. First, we need to understand...

MySQL 5.7.18 free installation version window configuration method

This is my first blog. It’s about when I started ...

mysql workbench installation and configuration tutorial under centOS

This article shares the MySQL Workbench installat...

Sample code for JS album image shaking and enlarging display effect

The previous article introduced how to achieve a ...

Several methods of implementing carousel images in JS

Carousel The main idea is: In the large container...

A brief discussion on the understanding of TypeScript index signatures

Table of contents 1. What is an index signature? ...