---
title: "解决hibernate3存取MySql5 乱码问题"
author: "kowen"
date: "2009-10-22T23:35:24Z"
tags: []
slug: "hibernate3-mysql5"
draft: false
lastmod: "2009-10-22T23:35:24Z"
id: 501233
url: "https://kowen.iteye.com/blog/501233"
---

1.设置Mysql5 默认编码为UTF-8

Linux 编辑/etc/my.cnf　,在段加入default_character_set=utf8
windows 编辑my.ini 在段加入default_character_set=utf8

2.在Hibernate连接串中加入字符集参数 useUnicode=true&amp;characterEncoding=UTF-8

例如：
<property name="connection.url">
jdbc:mysql://localhost:3306/test?useUnicode=true&amp;characterEncoding=UTF-8
</property>