mysql设置服务器编码

  今天写java程序的时候出现了插入mysql数据中文乱码问题,确定数据库和表的编码都已指定utf-8。百度后得知mysql安装后需设置服务器编码,以下是解决方法(ubuntu; mysql 5.6.25):

  1.确认现在的编码:登陆mysql后执行show variables like 'character%';

  2.查找mysql配置文件:find / -name '*.cnf'

  3.找到my.cnf,编辑,在[mysqld]下添加一句  character-set-server=utf8

      4.重启mysql: /etc/init.d/mysql restart并执行第一步重新查看编码。

原文地址:https://www.cnblogs.com/sheeva/p/4826707.html