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 add interface listening mask in Vue project

1. Business Background Using a mask layer to shie...

A brief analysis of Linux network programming functions

Table of contents 1. Create a socket 2. Bind sock...

MySQL join buffer principle

Table of contents 1. MySQL join buffer 2. JoinBuf...

File sharing between Ubuntu and Windows under VMware

This article records the method of sharing files ...

Two problems encountered when deploying rabbitmq with Docker

1. Background The following two problems are enco...

Sublime / vscode quick implementation of generating HTML code

Table of contents Basic HTML structure Generate s...

Example code and method of storing arrays in mysql

In many cases, arrays are often used when writing...

JavaScript event loop case study

Event loop in js Because JavaScript is single-thr...

Layim in javascript to find friends and groups

Currently, layui officials have not provided the ...

The process of installing and configuring nginx in win10

1. Introduction Nginx is a free, open source, hig...

MySQL 5.6 root password modification tutorial

1. After installing MySQL 5.6, it cannot be enabl...

JavaScript anti-shake and throttling explained

Table of contents Stabilization Throttling Summar...

Kali Linux Vmware virtual machine installation (illustration and text)

Preparation: 1. Install VMware workstation softwa...

How to install MySQL 5.7.29 with one click using shell script

This article refers to the work of 51CTO blog aut...

Four ways to combine CSS and HTML

(1) Each HTML tag has an attribute style, which c...