mysql修改編碼失敗的解決方法就是在連接url後加上程式碼「?useUnicode=true&characterEncoding=UTF-8」即可。
推薦:《mysql影片教學》
mysql 修改編碼不成功解決方法
問題描述:
改為UTF8之後,重新進入mysql,它又自動改回latin1
有個方法很簡單,在連接url後加上如下程式碼即可:
?useUnicode=true&characterEncoding=UTF-8
特別注意,兩個屬性之間一定要用&符號的轉義符,不能帶空格,否則會報錯。
範例如下hibernate.cfg.xml設定檔:
< hibernate-configuration > < session-factory > < property name = "dialect" > org.hibernate.dialect.MySQLDialect < property name = "connection.url" > jdbc:mysql://localhost:3306/share?useUnicode=true&characterEncoding=UTF-8 < property name = "connection.username" >root < property name = "connection.password" >accp < property name = "connection.driver_class" > com.mysql.jdbc.Driver < property name = "myeclipse.connection.profile" >ssh < property name = "show_sql" >true < property name = "format_sql" >true < 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" />
=========================== ======
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;
以上是mysql 修改編碼失敗怎麼辦的詳細內容。更多資訊請關注PHP中文網其他相關文章!