设置MySQL编码方式

  • 查看编码格式
    SHOW VARIABLES LIKE 'character_set_%';

    character_set_

  • 依次设置编码格式

set character_set_client = utf8;
set character_set_connection = utf8;
set character_set_database = utf8;
set character_set_filesystem = utf8;
set character_set_results = utf8;
set character_set_server = utf8;
set collation_connection = utf8_general_ci;
set collation_database = utf8_general_ci;
  • 设置my.cnf配置文件
character-set-server=utf8
default-character-set=utf8
  • 重启mysqld 使配置生效
    sudo service mysqld restart

推荐阅读更多精彩内容