修改mysql 5.6.24解压缩版(免安装版)默认字符编码。


【目前官方最新版的MySQL数据库都只提供zip版的安装包。所以网上许多解决数据库默认编码的博客都不能使用了。这次安装数据库,总结出修改MySQL数据库默认编码的方法。】

1.安装数据库,

在官网下载zip版安装板包,解压到C盘根目录下(建议安装在C盘根目录下,不然会出现很多错误)。

配置好MySQL的环境变量后,我们通过 cmd 中的 mysqld -install 去安装相关数据库服务。在通过 net start mysql 去连接数据库。最后在通过 mysql -uroot -p 登录数据库。

输入 show variables like 'char%' 可以查看数据库的默认编码:如图。

     

可以发现各种编码不协调。

2.解决乱码问题:

找到你安装的MySQL目录,有个 my-default.ini的配置文件。这是MySQL数据库自带的配置文件,我们可以复制一份重名为my.ini。放在同一目录下。

用记事本打开my.ini文件,修改如下。 basedir  datadir  port 不用设置。不然会无法开启数据库服务。 这里加了4行代码,大家可以仔细对下。


# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/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]

# 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 = .....
character_set_server=utf8


# 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 
[client]
port=3306
default-character-set=utf8


3.检查:

依次键入 net stop mysql ,   net start mysql , 重启数据库服务。然后连接数据库。

键入查询编码的命令后,显示如下。代表我们编码修改成功。

        


如果还要什么安装问题,大家可以在下方留言。一起商量一下。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值