Home  >  Article  >  Database  >  Solution to Chinese garbled code in mysql5.5 database command line under Windows 10

Solution to Chinese garbled code in mysql5.5 database command line under Windows 10

小云云
小云云Original
2017-12-25 13:51:582073browse

After resetting the system, the MySQL database installed a long time ago has a problem with Chinese garbled characters in console queries. This article mainly shares with you the solution to Chinese garbled characters in the mysql5.5 database command line under Windows 10. I hope it can help everyone.

Open the my.ini file in the installation directory

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


[client]
default-character-set=utf8
port=3306
[mysql]
#网上下面这个 gbk 很多回答也是设置为utf8,结果就是乱码
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
修改完毕重启mysql,查看一下编码:
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\ |
+--------------------------+---------------------------------------------------------+
操作试试:
mysql> insert into per values('乱码解决');
Query OK, 1 row affected (0.00 sec)
mysql> select * from per;
+--------------+| 
name |
+--------------+| 
的纷纷从 ||
 乱码解决 |
+--------------+
3 rows in set (0.00 sec)

Related recommendations:

Detailed explanation of Chinese garbled code problem in mysql database

How to correct Chinese garbled code when MySQL inserts data manage?

How does php solve the problem of Chinese garbled characters?

The above is the detailed content of Solution to Chinese garbled code in mysql5.5 database command line under Windows 10. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn