时间:2021-06-04 07:52:38 | 栏目:Mysql | 点击:次
MySQL绿色版设置编码,以及1067错误
查看MySQL编码
SHOW VARIABLES LIKE 'char%';
因为当初安装时指定了字符集为UTF8,所以所有的编码都是UTF8。
修改character_set_client、character_set_results、character_set_connection为GBK, 就不会出现乱码了。但其实只需要修改character_set_client和character_set_results。
控制台的编码只能是GBK,而不能修改为UTF8,这就出现一个问题。客户端发送的数据是GBK,而character_set_client为UTF8,这就说明客户端数据到了服务器端后一定会出现乱码。既然不能修改控制台的编码,那么只能修改character_set_client为GBK了。
服务器发送给客户端的数据编码为character_set_result,它如果是UTF8,那么控制台使用GBK解码也一定会出现乱码。因为无法修改控制台编码,所以只能把character_set_result修改为GBK。
填上这句话:
下面是整体配置:
# 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] basedir = H:\MySQL datadir = H:\MySQL\data 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 = ..... # 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 = gbk
1067错误
注意my.ini里面的配置不要写错了,其实我们很多出现1067错误的都是my.ini里面配错了。
备注:
在windows10中,其实设置default-character-set = utf8,然后在cmd中进行操作也不会乱码。但是在windows8.1、windows7中就会乱码。所以在windows8.1、windows7中必须把default-character-set = gbk 设置为gbk
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!