1. 程式人生 > >linux mysql亂碼問題

linux mysql亂碼問題

mysql,發現都是亂碼,一堆問號,如下圖:

 

檢視mysql編碼

 

需要修改mysql編碼,開啟/etc/my.cnf 檔案

 

在下邊新增如下行

[client]
default_character_set=utf8
[mysqld]
collation_server = utf8_general_ci
character_set_server = utf8

 

修改後的/etc/my.cnf如下:

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user
=mysql # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid [client] default_character_set=utf8 [mysqld] collation_server = utf8_general_ci character_set_server = utf8

 

再檢視如下

 

已經修改過來了,重啟, 再繼續查詢,能正常顯示中文漢字,搞定。