Ubuntu+MySQL下JAVA开发中乱码问题的解决

WBOY
Release: 2016-06-07 16:53:50
Original
919 people have browsed it

环境: UbuntuMYSQL 5.0.38JDK 1.6Ecplise 3.2.2Hibernate 3.2Mysql query browser 1.2.5batejava project开发过程中发现Insert的

环境: Ubuntu
MYSQL 5.0.38
JDK 1.6
Ecplise 3.2.2
Hibernate 3.2
Mysql query browser 1.2.5bate
java project开发过程中发现Insert的数据都是乱码,,搜索了各种牛人的解决方案均未果。 尝试各种修改组合后终于解决。

1. 修改mysql的配置文件 sudo gedit /etc/mysql/my.cnf
增加 default-character=utf8

2. 在mysql shell下建立数据库.
create database pencat default character set utf8;

3. 建立table.
CREATE TABLE `pencat`.`USER` (
`user_id` int(11) NOT NULL auto_increment,
`name` varchar(160) NOT NULL,
`sex` char(1) default NULL,
`age` int(11) default NULL,
PRIMARY KEY (`user_id`)
) ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;

至此,问题全部解决。 插入,读取,GUI下的管理都是中文了。

linux

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!