Mysql儲存enjoy圖片

來源:互聯網
上載者:User

標籤:http   mes   亂碼   儲存   char   nec   efault   unicode   需要   


修改mysql 的  my.ini檔案   ,添加

[client] default-character-set=utf8mb4

port=3306

[mysql]

default-character-set=utf8mb4

[mysqld]

port=3306

character-set-client-handshake = FALSE

character-set-server=utf8mb4

#collation-server = utf8mb4_unicode_ci //如果改這個tomcat會連不上資料庫,不知道為什麼,只能注釋了。

init_connect=‘SET NAMES utf8mb4‘//如果不在此設定,就需要在代碼中串連資料庫時加上了。


在將mysql中從庫到表都編碼改為utf8mb4,需要mysql5.5以上才支援utf8mb4,具體操作就不多說了,可以手打命令,也可以通過像類似mysql-front這樣的工具。

最後要改的就是本地程式,首先需要把jdbc驅動包換成最新的,至少要5.1.x;
然後需要串連資料庫路徑改為如下:

jdbc:mysql://localhost:3306/spider?characterEncoding=utf8

必須要加上characterEncoding=utf8,這樣插入查詢資料庫時會自動的轉為utf8mb4,否則還會是亂碼

其他的就不用變了,utf8mb4向下相容utf8,只是能表示更多的位元組。

轉自:http://blog.csdn.net/woaigaolaoshi/article/details/51099783

Mysql儲存enjoy圖片

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.