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:/MySQLdatadir = H:/MySQL/datacharacter_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=3306default-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
感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
新聞熱點
疑難解答