mysql中文亂碼徹底解決
阿新 • • 發佈:2019-02-08
1.在mysql的配置檔案my.ini中新增:
[mysqld]
port = 3306
socket = /tmp/mysql.sock
character-set-server=utf8
character-set-filesystem = utf8
[client]
password = your password
port = 3306
socket = /tmp/mysql.sock
default-character-set=utf8
特別注意:mysql的預設配置檔案是my-default.ini,一定要複製一份改成my.ini,在my.ini裡配置,否則配置不會和生效。
2.配置之後,使用命令 show variables like ‘character%’;檢視效果
mysql> show variables like 'character%';
+--------------------------+----------------------------------------------------+
| Variable_name | Value |
+--------------------------+----------------------------------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | utf8 |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8