Ubuntu mysql編譯亂碼終于成功
Ubuntu mysql系統(tǒng)的特性,并結合應用實例進行講解,既可作為高校計算機專業(yè)Ubuntu mysql學習,也可以作為Ubuntu mysql系統(tǒng)開源愛好者、Ubuntu mysql系統(tǒng)用戶的學習。
先看下面注意內容整整弄了一天,終于解決了jdbc(mysql-connector-java-5.0.30)和Ubuntu mysql通信中文亂碼的問題!我的系統(tǒng)是linux(Ubuntu)。在java中(Myeclipse環(huán)境)使用hibernate連接Ubuntu mysql。存儲英文沒問題,寫(insertinto)和讀(select)都能正確顯示,但是若其中帶有中文字符就成亂碼了。到網(wǎng)上查找了半天資料,***終于成功。
我的解決方法是,在/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這樣改變后原先所建數(shù)據(jù)庫似乎不能用(不確定),盡量備份新建數(shù)據(jù)庫,就不會有亂碼了。
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="" />
【編輯推薦】