MySQL綠色版設(shè)置編碼,以及1067錯(cuò)誤
查看MySQL編碼
SHOW VARIABLES LIKE 'char%';
因?yàn)楫?dāng)初安裝時(shí)指定了字符集為UTF8,所以所有的編碼都是UTF8。
- character_set_client:你發(fā)送的數(shù)據(jù)必須與client指定的編碼一致!??!服務(wù)器會(huì)使用該編碼來(lái)解讀客戶端發(fā)送過(guò)來(lái)的數(shù)據(jù);
- character_set_connection:通過(guò)該編碼與client一致!該編碼不會(huì)導(dǎo)致亂碼!當(dāng)執(zhí)行的是查詢語(yǔ)句時(shí),客戶端發(fā)送過(guò)來(lái)的數(shù)據(jù)會(huì)先轉(zhuǎn)換成connection指定的編碼。但只要客戶端發(fā)送過(guò)來(lái)的數(shù)據(jù)與client指定的編碼一致,那么轉(zhuǎn)換就不會(huì)出現(xiàn)問(wèn)題;
- character_set_database:數(shù)據(jù)庫(kù)默認(rèn)編碼,在創(chuàng)建數(shù)據(jù)庫(kù)時(shí),如果沒(méi)有指定編碼,那么默認(rèn)使用database編碼;
- character_set_server:MySQL服務(wù)器默認(rèn)編碼;
- character_set_results:響應(yīng)的編碼,即查詢結(jié)果返回給客戶端的編碼。這說(shuō)明客戶端必須使用result指定的編碼來(lái)解碼;
修改character_set_client、character_set_results、character_set_connection為GBK,
就不會(huì)出現(xiàn)亂碼了。但其實(shí)只需要修改character_set_client和character_set_results。
控制臺(tái)的編碼只能是GBK,而不能修改為UTF8,這就出現(xiàn)一個(gè)問(wèn)題??蛻舳税l(fā)送的數(shù)據(jù)是GBK,而character_set_client為UTF8,這就說(shuō)明客戶端數(shù)據(jù)到了服務(wù)器端后一定會(huì)出現(xiàn)亂碼。既然不能修改控制臺(tái)的編碼,那么只能修改character_set_client為GBK了。
服務(wù)器發(fā)送給客戶端的數(shù)據(jù)編碼為character_set_result,它如果是UTF8,那么控制臺(tái)使用GBK解碼也一定會(huì)出現(xiàn)亂碼。因?yàn)闊o(wú)法修改控制臺(tái)編碼,所以只能把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錯(cuò)誤
注意my.ini里面的配置不要寫錯(cuò)了,其實(shí)我們很多出現(xiàn)1067錯(cuò)誤的都是my.ini里面配錯(cuò)了。
備注:
在windows10中,其實(shí)設(shè)置default-character-set = utf8,然后在cmd中進(jìn)行操作也不會(huì)亂碼。但是在windows8.1、windows7中就會(huì)亂碼。所以在windows8.1、windows7中必須把default-character-set = gbk 設(shè)置為gbk
感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!
您可能感興趣的文章:- Window 下安裝Mysql5.7.17 及設(shè)置編碼為utf8的方法
- mysql默認(rèn)編碼為UTF-8 通過(guò)修改my.ini實(shí)現(xiàn)方法
- mysql中數(shù)據(jù)庫(kù)與數(shù)據(jù)表編碼格式的查看、創(chuàng)建及修改
- MySQL中使用SQL語(yǔ)句查看某個(gè)表的編碼方法
- MySQL查看和修改字符編碼的實(shí)現(xiàn)方法
- Linux使用MySQL忘記root密碼及修改MySQL默認(rèn)編碼
- MySQL修改默認(rèn)字符集編碼的方法
- MySQL字符編碼設(shè)置方法