ubuntu中mysql乱码问题

 先看下面注意内容
整整弄了一天,终于解决了jdbc(mysql-connector-java-5.0.30)和mysq通信中文乱码的问题!我的系统是
linux(ubuntu)。在java中(Myeclipse环境)使用hibernate连接mysql。存储英文没问题,写(insert
into)和读(select)都能正确显示,但是若其中带有中文字符就成乱码了。到网上查找了半天资料,最后
终于成功。
我的解决方法是,在/etc/my.cnf文件中加上以下两行内容:
[client]default-character-set=utf8[mysqld]default-character-set=utf8
注意,这个文件不一定存在,需将 /安装原文件/support-files/my-medium.cnf 复制到/etc/下,重命名
需重启mysql
停用:sudo /usr/local/mysql/bin/mysqladmin shutdown
启用sudo /usr/local/mysql/bin/mysqld_safe -user=mysql &
查看mysql编码
启用后sudo /usr/local/mysql/bin/mysql
mysql>show variables like 'character%';
-------------------------- ----------------------------
| Variable_name | Value |
-------------------------- ----------------------------
| 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 |
| character_sets_dir | /usr/share/mysql/charsets/ |
-------------------------- ----------------------------
注意,这样改变后原先所建数据库似乎不能用(不确定),尽量备份
新建数据库,就不会有乱码了。
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window/nCTRL Mouse wheel to zoom in/out';}" οnmοuseοver="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window/nCTRL Mouse wheel to zoom in/out';}" οnclick="if(!this.resized) {return true;} else {window.open('http://www.cublog.cn/images/face/001.gif');}" onmousewheel="return imgzoom(this);" alt="" />

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值