WordPress 2.5.1 升級變亂碼

最近比較忙嗎?

WordPress 2.5 出來好一陣子了,今天來更新吧!

可能會停機 30 min!結果…

結果…

更新完網頁變亂碼了!

解決方案:
#1 懶人鋸箭法
將 wp-config.php 的以下兩行去掉或在行首加上 //
// define(‘DB_CHARSET’, ‘utf8′);
// define(‘DB_COLLATE’, ‘utf8_general_ci’);

#2 追根就底法
產生亂碼的原因是 mysql 資料庫中的資料的編碼是 latin1 而非 utf8
可以利用 phpMyAdmin 檢視資料庫中的內容:在 MySQL 文字編碼: UTF-8 Unicode (utf8 ) 且 MySQL 連線校對 : utf8_general_ci 時,瀏覽資料庫內容為亂碼,但此時 wordpress 中的中文字且正常 。

解法:將資料庫的內容編碼由 latin1 轉成 utf8 (1, 2)

  1. 將資料以 latin1 編碼轉出來
    mysqldump -uuser -ppassword sql_name --default-character-set=latin1 > xxxxxx.sql
  2. 修改轉出來的資料
    “SET NAMES latin1″ 改成 “SET NAMES utf8″
    “DEFAULT CHARSET=latin1″ 改成 “DEFAULT CHARSET=utf8″
  3. 將資料以 utf8 編碼倒到資料庫中
    cat xxxxxx.sql | mysql --default-character-set=utf8 -uuser -p password sql_name
  4. 修改並確認
    MySQL 文字編碼: UTF-8 Unicode (utf8 )
    MySQL 連線校對 : utf8_general_ci
  5. wp-config.php 維持原來的設定即可

標籤: , ,

一個回應 to “WordPress 2.5.1 升級變亂碼”

  1. 豆花 說:

    請問你的網站 “留言”這邊的中文是如何改出來的

    我的網站這邊一直顯示是英文

發表迴響

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 變更 )

Twitter picture

You are commenting using your Twitter account. Log Out / 變更 )

Facebook照片

You are commenting using your Facebook account. Log Out / 變更 )

連結到 %s


Follow

Get every new post delivered to your Inbox.