解决Windows10下mysql5.5数据库命令行中文乱码问题
程序员文章站
2023-11-18 22:03:34
重置系统后,很久之前安装的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)
总结
以上所述是小编给大家介绍的 关于windows10下解决mysql5.5数据库命令行中文乱码问题,希望对大家有所帮助
上一篇: Oracle监听口令及监听器安全详解
下一篇: Yii2.0框架模型多表关联查询示例