• 技术文章 >数据库 >mysql教程

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

    小云云小云云2017-12-25 13:51:58原创255
    重置系统后,很久之前安装的MySQL数据库出现了控制台查询中文乱码问题,本文主要和大家分享Windows10下mysql5.5数据库命令行中文乱码解决方案,希望能帮助到大家。

    打开安装目录下的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插入数据时遇到中文乱码改怎么办?

    php如何解决中文乱码问题?

    以上就是Windows10下mysql5.5数据库命令行中文乱码解决方案的详细内容,更多请关注php中文网其它相关文章!

    本文原创发布php中文网,转载请注明出处,感谢您的尊重!
    专题推荐:Windows10 mysql5.5 命令行
    上一篇:MySQL死锁与日志分析 下一篇:两种lnmp重置mysql数据库root密码的方法

    相关文章推荐

    • MySQL的show profile(已过时)简介以及该功能在MySQL 5.7中performance_schema中的替代• MySQL— 进阶• Linux下MySQL5.7.18 yum方式从卸载到安装• MySQL客户端工具的选择• MySQL入门学习(二)_MySQL

    全部评论我要评论

  • 取消发布评论发送
  • 1/1

    PHP中文网