首先,本人对mysql5.7.12不喜欢,安装不易,各种问题,其次这个字符集设置也是困难重重,这里先贴上我的my.ini,也就是那个my-default.ini,
<code class="language-html"># 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]# 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:Mysqlmysql-5.7.12-winx64 datadir = D:Mysqlmysql-5.7.12-winx64data port = 3306# 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 #--------------------------------------------------------[mysqld]basedir=D:Mysqlmysql-5.7.12-winx64datadir=D:Mysqlmysql-5.7.12-winx64datacharacter-set-server=utf8init_connect = 'SET NAMES utf8'[WinMySQLAdmin]Server=D:Mysqlmysql-5.7.12-winx64binmysqld.exedefault-character-set=utf8[client]port=3306default-character-set=utf8
为了改变所有字符为utf8,我查阅了网上很多资料,有很多人误导用SET character_set_client = utf8;
SET character_set_results = utf8;
SET character_set_connection = utf8;
这些命令来改变,其实下一次还是会回到初始值,然后还有一部分厉害一点的知道让你改变配置文件,
然而在5.7.12中,即使你改了配置文件仍然会绝望地发现,在敲出show variables like '%character%';仍然没有变化
+————————–+———————————————-+
| Variable_name | Value |
+————————–+———————————————-+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | D:Mysqlmysql-5.7.12-winx64sharecharsets |
+————————–+———————————————-+
这是我改变了my.ini之后的结果,之前还有人建议修改bin目录下的myinstant.conf这类的文件,然而mysql.5.7.12根本没有这个应用程序,
一切回到了原点,仔细看上面的结果,发现字符设置的目录在share目录下的charasets中,然后打开之后,完全看不懂啊 ,到这里真的心好累了,
再说一句如果你是普通用户也许按照上面的配置文件就可以了,然而对于root用户就不能做出什么改变了。
原创文章,作者:筱凯,如若转载,请注明出处:https://www.jingyueyun.com/ask/243.html