Mac 上 mysql 中文亂碼解決方案

打開終端 連接上mysql?

然后 輸入:show variables like '%char%';

出現(xiàn)以下:

說明你的 數(shù)據(jù)庫 編碼不正確

那么 我們 就去 改變 mysql 編碼配置

首先 復(fù)制以下代碼囱皿,并保存成 my.cnf 文件

# 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



保存my.cnf 文件 之后?

在終端 輸入 open /etc/

然后 把my.cnf 文件 放到 /etc 文件中

如圖:


這個時候 再去重啟mysql 就大功告成



最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末沥曹,一起剝皮案震驚了整個濱河市赊瞬,隨后出現(xiàn)的幾起案子揽思,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 217,826評論 6 506
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異,居然都是意外死亡铺遂,警方通過查閱死者的電腦和手機,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,968評論 3 395
  • 文/潘曉璐 我一進店門剪廉,熙熙樓的掌柜王于貴愁眉苦臉地迎上來娃循,“玉大人,你說我怎么就攤上這事斗蒋“聘” “怎么了笛质?”我有些...
    開封第一講書人閱讀 164,234評論 0 354
  • 文/不壞的土叔 我叫張陵,是天一觀的道長捞蚂。 經(jīng)常有香客問我妇押,道長,這世上最難降的妖魔是什么姓迅? 我笑而不...
    開封第一講書人閱讀 58,562評論 1 293
  • 正文 為了忘掉前任敲霍,我火速辦了婚禮,結(jié)果婚禮上丁存,老公的妹妹穿的比我還像新娘肩杈。我一直安慰自己,他們只是感情好解寝,可當我...
    茶點故事閱讀 67,611評論 6 392
  • 文/花漫 我一把揭開白布扩然。 她就那樣靜靜地躺著,像睡著了一般聋伦。 火紅的嫁衣襯著肌膚如雪夫偶。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,482評論 1 302
  • 那天觉增,我揣著相機與錄音兵拢,去河邊找鬼。 笑死逾礁,一個胖子當著我的面吹牛说铃,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播嘹履,決...
    沈念sama閱讀 40,271評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼截汪,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了植捎?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,166評論 0 276
  • 序言:老撾萬榮一對情侶失蹤阳柔,失蹤者是張志新(化名)和其女友劉穎焰枢,沒想到半個月后,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體舌剂,經(jīng)...
    沈念sama閱讀 45,608評論 1 314
  • 正文 獨居荒郊野嶺守林人離奇死亡济锄,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,814評論 3 336
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了霍转。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片荐绝。...
    茶點故事閱讀 39,926評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖避消,靈堂內(nèi)的尸體忽然破棺而出低滩,到底是詐尸還是另有隱情召夹,我是刑警寧澤,帶...
    沈念sama閱讀 35,644評論 5 346
  • 正文 年R本政府宣布恕沫,位于F島的核電站监憎,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏婶溯。R本人自食惡果不足惜鲸阔,卻給世界環(huán)境...
    茶點故事閱讀 41,249評論 3 329
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望迄委。 院中可真熱鬧褐筛,春花似錦、人聲如沸叙身。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,866評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽曲梗。三九已至赞警,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間虏两,已是汗流浹背愧旦。 一陣腳步聲響...
    開封第一講書人閱讀 32,991評論 1 269
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留定罢,地道東北人笤虫。 一個月前我還...
    沈念sama閱讀 48,063評論 3 370
  • 正文 我出身青樓,卻偏偏與公主長得像祖凫,于是被迫代替她去往敵國和親琼蚯。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 44,871評論 2 354

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