關於mysql字元編碼設定

來源:互聯網
上載者:User

標籤:alarm   中文   亂碼   use   網上   mysq   不同   5.5   reconnect   


在mysql中插入資料一直顯示是???亂碼。網上非常多人說的試了都不正確,後來經過大量查詢資料,將解決方式寫在以下。不同的版本號碼有不同的解決方式吧。我的資料庫版本號碼(5.5.40)

[client]

default-character-set=utf8
[mysql]
default-character-set=utf8
[mysqld]
collation-server = utf8_unicode_ci
init-connect=’SET NAMES utf8′

character-set-server = utf8


更新:2014-12-27

後來在用hibernate插入資料時發現插入到了mysql資料庫是亂碼,於是改了資料庫配置,用的spring mvc的架構,在web.xml中添加了filter,改了jsp頁面的編碼。發現顯示和在資料庫中直接用insert插入中文都是好的。僅僅是在用hibernate的save時插入資料庫有亂碼,最後發現hibernate的save操作沒實用utf8的編碼。

我是這樣改的,在hibernate的設定檔裡改了配置例如以下

jdbc.url=jdbc:mysql://58.210.161.122/fpp_alarm_client?

createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=utf8&autoReconnect=true



關於mysql字元編碼設定

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.