修改mysql編碼為utf-8

下面的操作都是在Mac系統(tǒng)下進(jìn)行的,每個(gè)步驟都是我做過(guò)的厚脉。親測(cè)有效。

1. 打開(kāi)命令行步藕,查看當(dāng)前mysql編碼狀態(tài)

SHOW VARIABLES LIKE 'character%';

如下圖:


改變之前.png

2. 打開(kāi)finder惦界,進(jìn)入etc文件夾

在finder界面,按住shift+command+g咙冗,就會(huì)出現(xiàn)下圖界面沾歪,在輸入框中輸入/etc:

文件夾跳轉(zhuǎn).png

3. 在etc文件夾內(nèi),查看是否有my.cnf文件雾消,打開(kāi)并用下面的內(nèi)容覆蓋它灾搏。如果沒(méi)有,就新建一個(gè)立润,然后把下面的內(nèi)容復(fù)制進(jìn)去狂窑。

# Example MySQL config file for small systems.  
#  
# This is for a system with little memory (<= 64M) where MySQL is only used  
# from time to time and it's important that the mysqld daemon  
# doesn't use much resources.  
#  
# MySQL programs look for option files in a set of  
# locations which depend on the deployment platform.  
# You can copy this option file to one of those  
# locations. For information about these locations, see:  
# http://dev.mysql.com/doc/mysql/en/option-files.html  
#  
# In this file, you can use all long options that a program supports.  
# If you want to know which options a program supports, run the program  
# with the "--help" option.  
 
# The following options will be passed to all MySQL clients  
[client]  
default-character-set=utf8  
#password   = your_password  
port        = 3306 
socket      = /tmp/mysql.sock  
 
# Here follows entries for some specific programs  
 
# The MySQL server   
[mysqld]  
default-storage-engine=INNODB  
character-set-server=utf8  
collation-server=utf8_general_ci  
port        = 3306 
socket      = /tmp/mysql.sock  
skip-external-locking  
key_buffer_size = 16K  
max_allowed_packet = 1M  
table_open_cache = 4 
sort_buffer_size = 64K  
read_buffer_size = 256K  
read_rnd_buffer_size = 256K  
net_buffer_length = 2K  
thread_stack = 128K  
 
# Don't listen on a TCP/IP port at all. This can be a security enhancement,  
# if all processes that need to connect to mysqld run on the same host.  
# All interaction with mysqld must be made via Unix sockets or named pipes.  
# Note that using this option without enabling named pipes on Windows  
# (using the "enable-named-pipe" option) will render mysqld useless!  
#   
#skip-networking  
server-id   = 1 
 
# Uncomment the following if you want to log updates  
#log-bin=mysql-bin  
 
# binary logging format - mixed recommended  
#binlog_format=mixed  
 
# Causes updates to non-transactional engines using statement format to be  
# written directly to binary log. Before using this option make sure that  
# there are no dependencies between transactional and non-transactional  
# tables such as in the statement INSERT INTO t_myisam SELECT * FROM  
# t_innodb; otherwise, slaves may diverge from the master.  
#binlog_direct_non_transactional_updates=TRUE  
 
# Uncomment the following if you are using InnoDB tables  
#innodb_data_home_dir = /usr/local/mysql/data  
#innodb_data_file_path = ibdata1:10M:autoextend  
#innodb_log_group_home_dir = /usr/local/mysql/data  
# You can set .._buffer_pool_size up to 50 - 80 %  
# of RAM but beware of setting memory usage too high  
#innodb_buffer_pool_size = 16M  
#innodb_additional_mem_pool_size = 2M  
# Set .._log_file_size to 25 % of buffer pool size  
#innodb_log_file_size = 5M  
#innodb_log_buffer_size = 8M  
#innodb_flush_log_at_trx_commit = 1 
#innodb_lock_wait_timeout = 50 
 
[mysqldump]  
quick  
max_allowed_packet = 16M  
 
[mysql]  
no-auto-rehash  
# Remove the next comment character if you are not familiar with SQL  
#safe-updates  
 
[myisamchk]  
key_buffer_size = 8M  
sort_buffer_size = 8M  
 
[mysqlhotcopy]  
interactive-timeout 

4. 重啟mysql

5. 再次進(jìn)入命令行,輸入之前的命令

SHOW VARIABLES LIKE 'character%';

如果看到下圖所示桑腮,就成功了泉哈。


改變之后.png

祝你幸福。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末破讨,一起剝皮案震驚了整個(gè)濱河市丛晦,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌添忘,老刑警劉巖采呐,帶你破解...
    沈念sama閱讀 218,122評(píng)論 6 505
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異搁骑,居然都是意外死亡,警方通過(guò)查閱死者的電腦和手機(jī)又固,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,070評(píng)論 3 395
  • 文/潘曉璐 我一進(jìn)店門仲器,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái),“玉大人仰冠,你說(shuō)我怎么就攤上這事乏冀。” “怎么了洋只?”我有些...
    開(kāi)封第一講書人閱讀 164,491評(píng)論 0 354
  • 文/不壞的土叔 我叫張陵辆沦,是天一觀的道長(zhǎng)。 經(jīng)常有香客問(wèn)我识虚,道長(zhǎng)肢扯,這世上最難降的妖魔是什么? 我笑而不...
    開(kāi)封第一講書人閱讀 58,636評(píng)論 1 293
  • 正文 為了忘掉前任担锤,我火速辦了婚禮蔚晨,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘肛循。我一直安慰自己铭腕,他們只是感情好银择,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,676評(píng)論 6 392
  • 文/花漫 我一把揭開(kāi)白布。 她就那樣靜靜地躺著累舷,像睡著了一般浩考。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上被盈,一...
    開(kāi)封第一講書人閱讀 51,541評(píng)論 1 305
  • 那天析孽,我揣著相機(jī)與錄音,去河邊找鬼害捕。 笑死绿淋,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的尝盼。 我是一名探鬼主播吞滞,決...
    沈念sama閱讀 40,292評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼盾沫!你這毒婦竟也來(lái)了裁赠?” 一聲冷哼從身側(cè)響起,我...
    開(kāi)封第一講書人閱讀 39,211評(píng)論 0 276
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤赴精,失蹤者是張志新(化名)和其女友劉穎佩捞,沒(méi)想到半個(gè)月后,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體蕾哟,經(jīng)...
    沈念sama閱讀 45,655評(píng)論 1 314
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡一忱,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,846評(píng)論 3 336
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了谭确。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片帘营。...
    茶點(diǎn)故事閱讀 39,965評(píng)論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖逐哈,靈堂內(nèi)的尸體忽然破棺而出芬迄,到底是詐尸還是另有隱情,我是刑警寧澤昂秃,帶...
    沈念sama閱讀 35,684評(píng)論 5 347
  • 正文 年R本政府宣布禀梳,位于F島的核電站,受9級(jí)特大地震影響肠骆,放射性物質(zhì)發(fā)生泄漏算途。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,295評(píng)論 3 329
  • 文/蒙蒙 一哗戈、第九天 我趴在偏房一處隱蔽的房頂上張望郊艘。 院中可真熱鬧,春花似錦、人聲如沸纱注。這莊子的主人今日做“春日...
    開(kāi)封第一講書人閱讀 31,894評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)狞贱。三九已至刻获,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間瞎嬉,已是汗流浹背蝎毡。 一陣腳步聲響...
    開(kāi)封第一講書人閱讀 33,012評(píng)論 1 269
  • 我被黑心中介騙來(lái)泰國(guó)打工, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留氧枣,地道東北人沐兵。 一個(gè)月前我還...
    沈念sama閱讀 48,126評(píng)論 3 370
  • 正文 我出身青樓,卻偏偏與公主長(zhǎng)得像便监,于是被迫代替她去往敵國(guó)和親扎谎。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,914評(píng)論 2 355

推薦閱讀更多精彩內(nèi)容