产生乱码原因

因为windows终端的默认字符集是gbk编码,而mysql数据库是utf8的编码,所以会产生乱码问题

解决乱码问题(临时修改)

询当前数据库默认编码:

mysql> show variables like 'character%';

修改为gbk编码:

mysql> set names gbk;

但是这只是临时修改,对新开启的终端无效。

解决乱码问题(永久)

修改MySQL的配置文件:my-default.ini

配置文件位于MySQL的安装目录

例如我的:C:\Program Files\MySQL\MySQL Server 5.7

[mysqld]character-set-server=gbk
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL. [mysqld]character-set-server=gbk # Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M # Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin # These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = ..... # Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

my-default.ini

Windows下永久解决数据库乱码 utf8 转 gbk的更多相关文章

  1. [转]Git for windows 下vim解决中文乱码的有关问题

    Git for windows 下vim解决中文乱码的问题 原文链接:Git for windows 下vim解决中文乱码的有关问题 1.右键打开Git bash: 2.cd ~ 3.vim .vim ...

  2. windows下git bash中文乱码解决办法

    一.解决办法1:(直接上图) 1.在git bash下,右键 出现下图,选择options: 2.选择“Text” 3.将“Character set”设置为  UTF-8 转:windows下git ...

  3. Windows下更改MySQL数据库的存储位置

    在MySQL安装完成后,要修改数据库存储的位置,比如从安装目录下的C:\Program Files\MySQL\MySQL Server 5.0\Data文件夹转移到D:\mySQLData文件夹. ...

  4. windows下cmd命令行显示UTF8字符设置(CHCP命令)

    本文由 www.169it.com 收集整理 在中文Windows系统中,如果一个文本文件是UTF-8编码的,那么在CMD.exe命令行窗口(所谓的DOS窗口)中不能正确显示文件中的内容.在默认情况下 ...

  5. Windows下如何解决git bash的默认home目录路径问题

    转自:http://blog.csdn.net/lucien_zhou/article/details/62069246 为了解决这个问题,我在网上找了好久,尝试过按网上其他人所述,修改 git 安装 ...

  6. 基于Windows下永久破解jetbrains公司的系列产品(Idea, pycharm,clion,phpstorm)

    基于Windows下永久破解jetbrains公司的系列产品(Idea, pycharm,clion,phpstorm): PS : 有能力的建议购买正版,好吧. PS:均针对其对应的2018.3.1 ...

  7. 解决windows下nginx中文文件名乱码

    我的根目录文件夹放在d盘work文件夹下,一般这样配置 nginx\conf\nginx.conf location / { root D:/work; index index_bak.html; a ...

  8. 记一次windows下物理迁移数据库的过程

    背景:      最近因为一次设备故障,导致一台运行windows环境下的机器无法启动,里面有一个正在使用的财务数据库,该数据库也只是每月使用一次,需要把物理数据迁移出来,于是拔出了故障机器的硬盘,通 ...

  9. windows下安装 sphinx 数据库全文搜索引擎

    此次演示的环境是:win7系统,64位,php5.4.x,apache sphinx,斯芬克斯(英语不好的同学可以直接读这个音),意狮身人面像 特点:创建索引速度快,3分钟左右能创建100万条记录的索 ...

随机推荐

  1. POJ 2309 BST(树状数组Lowbit)

    题意是给你一个满二叉树,给一个数字,求以这个数为根的树中最大值和最小值. 理解树状数组中的lowbit的用法. 说这个之前我先说个叫lowbit的东西,lowbit(k)就是把k的二进制的高位1全部清 ...

  2. 第三视角团队:"Jarvis For Chat"团队选题报告

    "Jarvis For Chat"团队选题报告 组长博客链接 本次作业链接 NABCD在项目中的使用 N(Need,需求) QQ和微信已经成为人们社交的必需品,在QQ有7.8亿活跃 ...

  3. C++字符串函数之append()、insert()

    仅记录自己比较容易忘的几个: B.insert(1,A,2,2) 将A中的从第3个字符开始的2个字符插入到B的第1个字符后面(字符串A和B实际上分别是const char [5]和const char ...

  4. [翻译]HTTP: Response Code

    原文地址:HTTP: Response Code 在上一篇文章中,我们总结说HTTP管理客户端和服务端之间的交互,并且解释HTTP头部的概念.在随后的系列文章中我们将讨论更多关于以下方面的信息:对交互 ...

  5. [转]CentOS 6和CentOS 7防火墙的关闭

      CentOS6.5查看防火墙的状态: 1 [linuxidc@localhost ~]$service iptable status 显示结果: 1 2 3 4 5 [linuxidc@local ...

  6. 15款Cocos2d-x游戏源码

    (1)用cocos2d-x开发的中国象棋游戏源码 使用Cocos2d-X2.2.3开发的一款中国象棋游戏,游戏中可以实现.新局面.悔棋.游戏音乐.胜利后会显示游戏结果. 源码下载:http://www ...

  7. 那些年,追寻JMeter的足迹,免费送……

    ​我们测试技术部武汉团队自16年引入jmeter以来,利用jmeter做了很多事情.首先运用jmeter进行接口测试,后续实现jmeter自动化冒烟测试,顺带也实现了线上环境的巡检,节省了大量人力.j ...

  8. Centos编译Unix网络编程(第三版)卷1的源代码

    测试环境:Centos 1)在shell中输入./configure然后按回车(注意先让configure有执行权限 chomd 777 configure) 2)依次进入lib.libfree.li ...

  9. [LeetCode&Python] Problem 561. Array Partition I

    Given an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1 ...

  10. codeforces1111 简单题【DE】简要题解

    D 很显然可以用一个背包算出来凑齐i个位置的方案 然后总的答案就是\(dp_{n / 2}\) 然后需要扣掉不符合条件的就是把选出来的数的贡献剪掉的贡献 然后注意因为是多重集合的排列,所以需要乘上\( ...