欢迎来到代码驿站!

Mysql

当前位置:首页 > 数据库 > Mysql

解决Windows10下mysql5.5数据库命令行中文乱码问题

时间:2021-06-01 08:52:31|栏目:Mysql|点击:

重置系统后,很久之前安装的MySQL数据库出现了控制台查询中文乱码问题,时间太久早已经不记得怎么设置了。

网上查询了许多,各种设置,重启数据库后仍然是中文乱码。

可能是我搜索方式不对,最后还好已经解决,特开一处女博记录一下:

打开安装目录下的my.ini文件

我的是:C:\Program Files\MySQL\MySQL Server 5.5下面,修改如下:

[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)

总结

上一篇:MySQL 主从同步,事务回滚的实现原理

栏    目:Mysql

下一篇:史上最简单的MySQL数据备份与还原教程(上)(三十五)

本文标题:解决Windows10下mysql5.5数据库命令行中文乱码问题

本文地址:http://www.codeinn.net/misctech/133149.html

推荐教程

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:914707363 | 邮箱:codeinn#126.com(#换成@)

Copyright © 2020 代码驿站 版权所有