时间:2021-07-01 10:21:17 帮助过:15人阅读
在配置jdbc数据源的时候加上:
jdbc:mysql://127.0.0.1:3306/logistics?useUnicode=true&characterEncoding=UTF-8
存数据库操作后乱码,解决方案:
登录数据库,执行如下sql:
show variables like ‘character%‘;
结果:
| 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_set_database,character_set_server编码格式设置错误。
解决:
找到mysql安装路径下的my.cnf文件在[mysqld]下添加如下两行:
character_set_server=utf8
init_connect=‘SET NAMES utf8‘
再次查看,问题解决:
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8
web项目存数据到数据库,中文乱码,解决过程
标签:amp logistic ted 127.0.0.1 数据 span tab style web项目