Ubuntu mysql编译乱码终于成功

系统 Linux
先看下面注意内容整整弄了一天,终于解决了jdbc(mysql-connector-java-5.0.30)和Ubuntu mysql通信中文乱码的问题!我的系统是linux(Ubuntu)。在java中(Myeclipse环境)使用hibernate连接Ubuntu mysql。

Ubuntu mysql系统的特性,并结合应用实例进行讲解,既可作为高校计算机专业Ubuntu mysql学习,也可以作为Ubuntu mysql系统开源爱好者、Ubuntu mysql系统用户的学习。

先看下面注意内容整整弄了一天,终于解决了jdbc(mysql-connector-java-5.0.30)和Ubuntu mysql通信中文乱码的问题!我的系统是linux(Ubuntu)。在java中(Myeclipse环境)使用hibernate连接Ubuntu mysql。存储英文没问题,写(insertinto)和读(select)都能正确显示,但是若其中带有中文字符就成乱码了。到网上查找了半天资料,***终于成功。

我的解决方法是,在/etc/my.cnf文件中加上以下两行内容:
[client]default-character-set=utf8[mysqld]default-character-set=utf8
注意,这个文件不一定存在,需将 /安装原文件/support-files/my-medium.cnf 复制到/etc/下,重命名
需重启Ubuntu mysql
停用:sudo /usr/local/mysql/bin/mysqladmin shutdown
启用sudo /usr/local/mysql/bin/mysqld_safe -user=mysql &

查看Ubuntu 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/

注意,Ubuntu mysql这样改变后原先所建数据库似乎不能用(不确定),尽量备份新建数据库,就不会有乱码了。
 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';}" onmouseover="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';}" onclick="if(!this.resized) {return true;} else {window.open('http://www.cublog.cn/images/face/001.gif');}" onmousewheel="return imgzoom(this);" alt="" />

【编辑推荐】

  1. Ubuntu MySQL安装与配置文件
  2. 安装Ubuntu mysql解压配置编译
  3. Ubuntu mysql配置安装建立连接
  4. Ubuntu mysql服务器安装布局
  5. Ubuntu aptitude安装可用的软件包
责任编辑:佚名 来源: CSDN
相关推荐

2010-01-07 16:47:01

2011-07-05 14:29:44

Ubuntu QT Mysql

2023-06-07 19:17:14

UbuntuKDELinux

2010-02-06 16:13:49

Ubuntu Auda

2011-08-30 10:36:31

Ubuntu 9.04Mysql ProxyLua

2009-11-09 09:56:46

Driver Stud

2010-02-22 09:33:37

Ubuntu MySQ

2009-12-29 11:11:10

2010-01-04 10:06:56

Ubuntu gcc

2010-01-08 09:58:42

Ubuntu Secu

2011-05-16 10:31:19

mysql乱码

2017-09-14 16:28:45

中安威士

2009-05-08 16:41:47

LinuxUbuntu秘诀

2009-09-17 16:48:52

Ubuntu Day开源

2010-01-04 18:56:06

Ubuntu内核

2014-12-17 10:37:38

UbuntuHadoop

2010-02-06 17:08:58

Ubuntu ngin

2010-02-03 16:07:07

Ubuntu Auda

2010-01-06 15:54:42

Ubuntu乱码

2009-12-30 09:22:01

Ubuntu编译
点赞
收藏

51CTO技术栈公众号