Mac mysql 解决中文乱码问题
出现“???”之类的无法识别的乱码
到/etc目录下自己建一个my.cnf文件(需要最高权限,使用sudo su),然后写入内容:
[client]
default-character-set=utf8
[mysqld]
character-set-server=utf8
保存,修改。关掉重启mysql,OK。
查看数据库
status
Connection id: 11
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: less
Using outfile: ''
Using delimiter: ;
Server version: 5.7.18 MySQL Community Server (GPL)
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: utf8
Db characterset: utf8
Client characterset: utf8
Conn. characterset: utf8
UNIX socket: /tmp/mysql.sock
Uptime: 1 min 30 sec
Threads: 1 Questions: 16 Slow queries: 0 Opens: 110 Flush tables: 1 Open tables: 100 Queries per second avg: 0.177
已经变成UTF8 了。
如果还不行,就删掉数据库,重新建立。