1打开mysql控制台
2输入密码登录
3依次输入如下命令:
SET character_set_client = utf8 ;
SET character_set_connection = utf8 ;
SET character_set_database = utf8 ;
SET character_set_results = utf8 ;
SET character_set_server = utf8 ;
SET collation_connection = utf8 ;
SET collation_database = utf8 ;
SET collation_server = utf8 ;
SET NAMES 'utf8';
4重启mysql服务
5修改数据库连接,在数据库名称后面加入如下代码“?characterEncoding=UTF-8"”如:jdbc:mysql://127.0.0.1:3306/Demo?characterEncoding=UTF-8