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

Basic usage knowledge points of mini programs (very comprehensive, recommended!)

Table of contents What to do when registering an ...

MySql development of automatic synchronization table structure

Development Pain Points During the development pr...

Docker installation and deployment of Net Core implementation process analysis

1. Docker installation and settings #Install Cent...

MySQL 5.7.20 installation and configuration method graphic tutorial (win10)

This article shares the installation and configur...

How to use Antd's Form component in React to implement form functions

1. Construction components 1. A form must contain...

IE8 Beta 1 has two areas that require your attention

<br />Related articles: Web skills: Multiple...

Understanding and application scenarios of enumeration types in TypeScript

Table of contents 1. What is 2. Use Numeric Enume...

React implements a highly adaptive virtual list

Table of contents Before transformation: After tr...

Control the light switch with js

Use js to control the light switch for your refer...

How to use boost.python to call c++ dynamic library in linux

Preface Recently I started using robot framework ...

Nginx improves access speed based on gzip compression

1. Why does nginx use gzip? 1. The role of compre...

js to achieve floor scrolling effect

This article uses jQuery to implement the sliding...