1、當我們把zip文件格式解壓到指定目錄後,並且完成基本環境配置後,打開mysql 5.6.24會發現名為【my-default.ini】的文件。我們用記事本打開該文件會發現並沒有【default-character-set = xxx】或者【character_set_server=xxx】,怎麼回事呢?網上給出的許多方法都是直接修改這句話的xxx為utf8,不急,下面請看第二步:
2、復制該文件,並且命名為【my.ini】,這樣根目錄下就有兩個.ini文件了,一個是my-default.ini,一個是my.ini 。接下來我們只需修改my.ini裡面的內容就行了。請看第三步:
3、修改【my.ini】,
在[mysqld]下面添加 character_set_server=utf8,注意是【utf8】不是【utf-8】而且後面沒有任何標點符號;
在【sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES】這句話後面再添加三行:
[client]
port=3306
default-character-set=utf8
4、經過以上三步就ok了。保存後重啟服務器,登陸後在命令行輸入:【show variables like 'char%';】可查看默認字符集如下圖所示:
5、我的【my.ini】代碼,紅色代碼區為修改之處:
# 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] # 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-5.6.24-winx64 datadir = D:\mysql-5.6.24-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 [client] port=3306 default-character-set=utf8