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

Example code for converting Mysql query result set into JSON data

Mysql converts query result set into JSON data Pr...

Teach you a trick to achieve text comparison in Linux

Preface In the process of writing code, we will i...

Implementation of Nginx forwarding matching rules

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

Example tutorial on using the sum function in MySQL

Introduction Today I will share the use of the su...

Pure CSS to achieve cool charging animation

Let’s take a look at what kind of charging animat...

Implementation of CSS heart-shaped loading animation source code

Without further ado, let me show you the code. Th...

Detailed explanation of whereis example to find a specific program in Linux

Linux finds a specific program where is The where...

js simple and crude publish and subscribe sample code

What is Publish/Subscribe? Let me give you an exa...

Basic knowledge of MySQL learning notes

View Database show databases; Create a database c...

Briefly explain the use of group by in sql statements

1. Overview Group by means to group data accordin...

How to quickly modify the root password under CentOS8

Start the centos8 virtual machine and press the u...

Specific use of MySQL binlog_ignore_db parameter

Preface: After studying the previous article, we ...

CSS layout tutorial: How to achieve vertical centering

Preface I have been summarizing my front-end know...

Practice of dynamically creating dialog according to file name in vue+el-element

Table of contents background accomplish 1. Encaps...