您好,登錄后才能下訂單哦!
小編給大家分享一下MAC下如何修改mysql默認字符集為utf8,希望大家閱讀完這篇文章之后都有所收獲,下面讓我們一起去探討吧!
1,檢查默認安裝的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后續創建的表都是latin1字符集的,不是utf8,會造成一些麻煩。所以有必要修改my.cnf,在修改my.cnf之前一定要關閉mysql進程,不然會遇到mysql的sock不能連接的問題。
2,關閉mysqld后臺進程
系統偏好設置里面控制mysqld,避免了去找mysqld安裝位置的麻煩。
點擊 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
修改完畢之后再啟動mysql
4,檢查結果:
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)
修改完畢#
看完了這篇文章,相信你對“MAC下如何修改mysql默認字符集為utf8”有了一定的了解,如果想了解更多相關知識,歡迎關注億速云行業資訊頻道,感謝各位的閱讀!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。