This page looks plain and unstyled because you're using a non-standard compliant browser. To see it in its best form, please upgrade to a browser that supports web standards. It's free and painless.

一次滿足你所有願望!?
 偷尼的網誌 | 偷尼的相簿 | 偷尼的名片                      ※ 使用鍵盤輸入 上上下下左右左右AB 後可進入裏世界 !!
Album | Blog | Comment | Profile | Control Panel
KCTONY | 17 January,2007 7:43
Bookmark: HemiDemi MyShare Baidu Google Bookmarks Yahoo! My Web Del.icio.us Digg technorati furl Bookmark to:YouPush Bookmark to:你推我報

不管是PHP或JSP 如果寫入utf-8的資料
mysql跟程式其中一方沒有寫好的話
SQL內的資料會變成亂碼
可以用這個方法舊回


(1) 匯出資料並指定編碼 latin1 (如果出來還是亂碼就改 big5 看看)
mysqldump -u root -p –default-character-set=latin1 資料庫名稱 > backup.sql

(2) 用編輯器開 backup.sql,前幾行會有個
/*!40101 SET NAMES latin1 */;
改成 /*!40101 SET NAMES utf8 */;
然後存檔存成 UTF-8 格式

(3) 匯入資料
mysql -u root -p 資料庫名稱 < backup.sql
這樣裡面的資料就會是 utf-8 了

(4) 修改連線方式改成utf-8

Comment

Trackback

Comment Permissions: Allow commenting

Leave Comment

*Name/Nickname
E-mail
Personal Website
Comment Title
*Comment
* Private Comment