时间:2021-07-01 10:21:17 帮助过:39人阅读
MySQL绿色版设置编码,以及1067错误
查看MySQL编码
SHOW VARIABLES LIKE 'char%';
因为当初安装时指定了字符集为UTF8,所以所有的编码都是UTF8。
character_set_client:你发送的数据必须与client指定的编码一致!!!服务器会使用该编码来解读客户端发送过来的数据;
character_set_connection:通过该编码与client一致!该编码不会导致乱码!当执行的是查询语句时,客户端发送过来的数据会先转换成connection指定的编码。但只要客户端发送过来的数据与client指定的编码一致,那么转换就不会出现问题;
character_set_database:数据库默认编码,在创建数据库时,如果没有指定编码,那么默认使用database编码;
character_set_server:MySQL服务器默认编码;
character_set_results:响应的编码,即查询结果返回给客户端的编码。这说明客户端必须使用result指定的编码来解码;
修改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
以上就是MySQL绿色版设置编码以及1067错误详解的详细内容,更多请关注Gxl网其它相关文章!