今天下载安装mysql数据库就从官网选择了最新版5.6.20安装,安装过程中发现新版本只是安装数据库服务,已不再有配置选项了,只能自己手动配置,将数据库添加到服务以后遇到编码问题。由于5.6版本不再提供my.ini 的配置文件。且my-default.ini中也没有charset更改项,遂查找资料得出以下结论:
1.将根目录下的my-default.ini复制重命名为my.ini
2.打开my.ini文件,将下面的源码添加修改到my.ini中
character_set_server=utf8
basedir=D:\Program Files\MySQL\MySQL Server 5.6
datadir=D:\Program Files\MySQL\MySQL Server 5.6\data
完成后保存。
我添加完以后是这样的:
[mysqld]
character-set-server=utf8
# 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 = .....
basedir=D:\Program Files\MySQL\MySQL Server 5.6
datadir=D:\Program Files\MySQL\MySQL Server 5.6\data
然后重启服务执行命令:show variables like 'character%'
就发现下面的除了filesystem,其他的编码都是utf8了。