修改前执行如下命令 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/Cellar/mysql/5.7.21/share/mysql/charsets/ | +--------------------------+---------------------------------------------------------------+ 8 rows in set $ sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf 在 [mysqld] 域下加上: character-set-server=utf8 再重新启动 MySQL 服务即可: $ sudo systemctl restart mysql 这样就解决问题了。 (责任编辑:IT) |