mysql修改編碼失敗的解決方法就是在連接url後加上程式碼「?useUnicode=true&characterEncoding=UTF-8」即可。
推薦:《mysql影片教學》
mysql 修改編碼不成功解決方法
問題描述:
改為UTF8之後,重新進入mysql,它又自動改回latin1
有個方法很簡單,在連接url後加上如下程式碼即可:
?useUnicode=true&characterEncoding=UTF-8
特別注意,兩個屬性之間一定要用&符號的轉義符,不能帶空格,否則會報錯。
範例如下hibernate.cfg.xml設定檔:
xml version = '1.0' encoding = 'UTF-8' ?> < hibernate-configuration > < session-factory > < property name = "dialect" > org.hibernate.dialect.MySQLDialect property > < property name = "connection.url" > jdbc:mysql://localhost:3306/share?useUnicode=true&characterEncoding=UTF-8 property > < property name = "connection.username" >root property > < property name = "connection.password" >accp property > < property name = "connection.driver_class" > com.mysql.jdbc.Driver property > < property name = "myeclipse.connection.profile" >ssh property > < property name = "show_sql" >true property > < property name = "format_sql" >true property > < mapping resource = "cn/lihuoqing/po/ShUser.hbm.xml" /> < mapping resource = "cn/lihuoqing/po/ShOptions.hbm.xml" /> < mapping resource = "cn/lihuoqing/po/ShFiles.hbm.xml" /> < mapping resource = "cn/lihuoqing/po/ShComments.hbm.xml" /> < mapping resource = "cn/lihuoqing/po/ShDown.hbm.xml" /> session-factory > hibernate-configuration >
=========================== ======
1 修改資料庫層級
a. 暫時變更:
. 永久更改:
改變了伺服器級就可以了
2.修改表級
mysql>ALTER TABLE table_name DEFAULT CHARSET utf8;
## 修改範例:
mysql>alter table `products` change `products_model` `products_model` varchar( 20 ) character set utf8 collate utf8_general_ci null default null;變更後永久生效 4. mysql> ; set names utf8; b.永久改變: #my.ini檔案(linux 為my..cnf)#my. ## linux 下修改這裡容易遇到問題,出錯後請參考http://blog.csdn.net/zhongdajiajiao/article/details/51698845
以上是mysql 修改編碼失敗怎麼辦的詳細內容。更多資訊請關注PHP中文網其他相關文章!