1:事情是这样的,我下载了一个mysql5.6.34版本(windows版本的),下载下来后里面只有个my-default.ini,然后我就直接在my-default.ini
里面配置basedir,datadir,port。
2:然后我的javaweb程序连接数据库后,出现了中文乱码问题,我就来配置mysql的字符集。
3:我在my-default.ini配置结果如下:
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
[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 = D:\mysql-5.6.34-winx64
datadir = D:\mysql-5.6.34-winx64\data
port = 3306
character-set-server=utf8
# server_id = .....
4:我重启我的mysql服务,命令是net stop mysql,然后net start mysql
5:然而没有任何效果,我用root用户进入mysql,执行命令show variables like '%character%';
6:结果如下:(还是latin字符集)
9:我想了一下,网上很多人修改配置文件都成功了,为什么我没成功,我和他们环境的唯一区别就是,我用的的事my-default.ini,而他们用的是my.ini
10:于是我复制了一份my-default.ini将其改名成my.ini
11:安装上面的步骤,重复一次,搞定。就是这个问题
12:截图如下: