小編給大家分享一下MAC下如何修改mysql默認(rèn)字符集為utf8,希望大家閱讀完這篇文章之后都有所收獲,下面讓我們一起去探討吧!
創(chuàng)新互聯(lián)建站-專業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設(shè)、高性價(jià)比皇姑網(wǎng)站開發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫,直接使用。一站式皇姑網(wǎng)站制作公司更省心,省錢,快速模板網(wǎng)站建設(shè)找我們,業(yè)務(wù)覆蓋皇姑地區(qū)。費(fèi)用合理售后完善,十多年實(shí)體公司更值得信賴。1,檢查默認(rèn)安裝的mysql的字符集
mysql> show variables like '%char%';
+--------------------------+--------------------------------------------------------+
| Variable_name | Value |
+--------------------------+--------------------------------------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/local/mysql-5.5.23-osx10.6-x86_64/share/charsets/ |
+--------------------------+--------------------------------------------------------+
8 rows in set (0.00 sec)
character_set_database和character_set_server依然是latin1的字符集,也就是說mysql后續(xù)創(chuàng)建的表都是latin1字符集的,不是utf8,會(huì)造成一些麻煩。所以有必要修改my.cnf,在修改my.cnf之前一定要關(guān)閉mysql進(jìn)程,不然會(huì)遇到mysql的sock不能連接的問題。
2,關(guān)閉mysqld后臺(tái)進(jìn)程
系統(tǒng)偏好設(shè)置里面控制mysqld,避免了去找mysqld安裝位置的麻煩。
點(diǎn)擊 Stop MySQL Server
3,修改mysql配置文件/etc/my.cnf
sudo cp /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf
sudo vi /etc/my.cnf
[client]部分加入:
default-character-set=utf8
[mysqld]部分加入:
character-set-server=utf8
修改完畢之后再啟動(dòng)mysql
4,檢查結(jié)果:
mysql> show variables like '%char%';
+--------------------------+--------------------------------------------------------+
| Variable_name | Value |
+--------------------------+--------------------------------------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/local/mysql-5.5.23-osx10.6-x86_64/share/charsets/ |
+--------------------------+--------------------------------------------------------+
8 rows in set (0.00 sec)
修改完畢#
看完了這篇文章,相信你對(duì)“MAC下如何修改mysql默認(rèn)字符集為utf8”有了一定的了解,如果想了解更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!