Solve the Chinese garbled problem of mysql5.5 database command line under Windows 10

Solve the Chinese garbled problem of mysql5.5 database command line under Windows 10

After resetting the system, the MySQL database that I installed a long time ago had garbled Chinese characters in the console query. It has been so long that I have no idea how to set it up.

I searched a lot online and tried various settings, but after restarting the database, the Chinese characters are still garbled.

Maybe I searched in the wrong way, but luckily I solved it in the end. I’ll open a blog to record it:

Open the my.ini file in the installation directory

Mine is: C:\Program Files\MySQL\MySQL Server 5.5, modified as follows:

[client]
default-character-set=utf8
port=3306
[mysql]
#Many answers on the internet also set this gbk to utf8, but the result is garbled characters default-character-set=gbk
#SERVER SECTION
# ----------------------------------------------------------------------
## The following options will be read by the MySQL Server. Make sure that
# you have installed the server correctly (see above) so it reads this 
# file.
#
[mysqld]# The TCP/IP Port the MySQL Server will listen on
port=3306
#Path to installation directory. All paths are usually resolved relative to this.
basedir="C:/Program Files/MySQL/MySQL Server 5.5/"
#Path to the database root
datadir="C:/ProgramData/MySQL/MySQL Server 5.5/Data/"
# The default character set that will be used when a new schema or table is
# created and no character set is defined
character-set-server=utf8
collation-server=utf8_general_ci
After the modification is completed, restart mysql and check the code:
mysql> show variables like 'character_set%';
+--------------------------+---------------------------------------------------------+| 
Variable_name | Value |
+--------------------------+---------------------------------------------------------+|
 character_set_client | gbk || 
character_set_connection | gbk ||
 character_set_database | utf8 || 
character_set_filesystem | binary || 
character_set_results | gbk || 
character_set_server | utf8 ||
 character_set_system | utf8 ||
 character_sets_dir | C:\Program Files\MySQL\MySQL Server 5.5\share\charsets\ |
+--------------------------+---------------------------------------------------------+
Try it:
mysql> insert into per values('garbled code solution');
Query OK, 1 row affected (0.00 sec)
mysql> select * from per;
+--------------+| 
name |
+--------------+| 
From||
 Garbled code solution |
+--------------+
3 rows in set (0.00 sec)

Summarize

The above is what I introduced to you about solving the Chinese garbled code problem of the MySQL5.5 database command line under Windows10. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!

You may also be interested in:
  • How to use PHP mysql_fetch_row to query and obtain a list of data rows
  • 5 MySQL GUI tools recommended to help you with database management
  • A brief introduction to the command line tool mycli for operating MySQL database
  • Why should the number of rows in a single MySQL table not exceed 5 million?
  • PHP uses mysqli and pdo extensions to test and compare the execution efficiency of mysql database. Complete example
  • Will MySQL execute the update statement again if it has the same data as the original one?
  • IDEA uses properties configuration file to connect to MySQL database
  • How to use binlog for data recovery in MySQL
  • Detailed explanation of MySQL database Event scheduled execution tasks
  • Java connects, queries and modifies MySQL database
  • Detailed explanation of MySQL data rows and row overflow mechanism

<<:  In-depth analysis of the Linux kernel macro container_of

>>:  Detailed explanation of the usage of the alias command under Linux

Recommend

How to install pyenv under Linux

Prerequisites Need to install git Installation St...

SQL Server Comment Shortcut Key Operation

Batch comments in SQL Server Batch Annotation Ctr...

Explanation of the precautions for Mysql master-slave replication

1. Error error connecting to master 'x@xxxx:x...

MySQL 5.7.23 installation and configuration method graphic tutorial

This article records the installation tutorial of...

How to set the number of mysql connections (Too many connections)

During the use of mysql, it was found that the nu...

Detailed explanation of memory management of MySQL InnoDB storage engine

Table of contents Storage Engine Memory Managemen...

Beginners learn some HTML tags (3)

Beginners who are exposed to HTML learn some HTML...

Summarize the problems encountered in using Vue Element UI

Table of contents 1. DateTimePicker date selectio...

How to modify the root password of mysql under Linux

Preface The service has been deployed on MySQL fo...

How to install PHP7.4 and Nginx on Centos

Prepare 1. Download the required installation pac...

Vue uses drag and drop to create a structure tree

This article example shares the specific code of ...

How to choose the format when using binlog in MySQL

Table of contents 1. Three modes of binlog 1.Stat...

Summary of 10 amazing tricks of Element-UI

Table of contents el-scrollbar scroll bar el-uplo...

Methods for defragmenting and reclaiming space in MySQL tables

Table of contents Causes of MySQL Table Fragmenta...