小白笔记----------------------Mysql5.7.12之字符集设置

来源:互联网 发布:太原知达常青藤中学校 编辑:程序博客网 时间:2024/06/05 03:50
首先,本人对mysql5.7.12不喜欢,安装不易,各种问题,其次这个字符集设置也是困难重重,这里先贴上我的my.ini,也就是那个my-default.ini,
# 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:\Mysql\mysql-5.7.12-winx64 datadir = D:\Mysql\mysql-5.7.12-winx64\data 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:\Mysql\mysql-5.7.12-winx64datadir=D:\Mysql\mysql-5.7.12-winx64\datacharacter-set-server=utf8init_connect = 'SET NAMES utf8'[WinMySQLAdmin]Server=D:\Mysql\mysql-5.7.12-winx64\bin\mysqld.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:\Mysql\mysql-5.7.12-winx64\share\charsets\ |
+--------------------------+----------------------------------------------+

这是我改变了my.ini之后的结果,之前还有人建议修改bin目录下的myinstant.conf这类的文件,然而mysql.5.7.12根本没有这个应用程序,

一切回到了原点,仔细看上面的结果,发现字符设置的目录在share目录下的charasets中,然后打开之后,完全看不懂啊 ,到这里真的心好累了,

再说一句如果你是普通用户也许按照上面的配置文件就可以了,然而对于root用户就不能做出什么改变了。

0 0