Deprecated: Function ereg() is deprecated in /home/silence/blog.silence.idv.tw/wp-content/plugins/tantan-flickr/flickr.php on line 56

Deprecated: Assigning the return value of new by reference is deprecated in /home/silence/blog.silence.idv.tw/wp-content/plugins/tantan-flickr/flickr.php(83) : runtime-created function on line 1

Strict Standards: Non-static method TPGuestbook::get_instance() should not be called statically in /home/silence/blog.silence.idv.tw/wp-content/plugins/tp-guestbook/tp-guestbook.php on line 506

Strict Standards: call_user_func_array() expects parameter 1 to be a valid callback, non-static method GoogleSitemapGeneratorLoader::Enable() should not be called statically in /home/silence/blog.silence.idv.tw/wp-includes/plugin.php on line 311
SILENCE Blog » Blog 文章彙整 » 更改 MySQL 資料庫編碼
Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 934

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 935

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 934

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 935

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 934

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 935

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 934

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 935

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 934

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 935

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 934

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 935

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 934

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 935

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 934

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 935

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 934

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 935

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 934

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 935

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 934

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 935

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 934

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 935

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 934

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 935

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 934

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 935

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 934

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 935

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 934

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 935

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 934

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 935

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 934

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 935

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 934

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 935

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 934

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 935

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 934

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 935

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 934

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 935

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 934

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 935

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 934

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 935

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 934

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 935

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 934

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 935

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 934

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 935

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 934

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 935

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 934

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 935

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 934

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 935

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 934

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 935

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 934

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 935

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 934

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/silence/blog.silence.idv.tw/wp-includes/kses.php on line 935
SILENCE Blog

更改 MySQL 資料庫編碼

2006, 10月 31 1:27 pm

由於剛申請 Dreamhost 不久後﹐便匆匆忙忙搞 Blog﹐相簿搬移和設定
卻忘記注意 MySQL 編碼﹐後來在安裝 Ultimate Tag Warrior 這個 Plugin 時
發現有點不正常﹐去 check 後﹐才發覺了是編碼的問題…..
原來 Dreamhost 建立 database 的預設編碼是 latin1
而不是 utf8。搞得在 phpmyadmin 內看到的都是亂碼 XD
所以就得花點時間做轉換了。

以下為轉換步驟:

  1. 啟用 wordpress 內建的 database backup plugin﹐並做備份
  2. 將備份完的 .sql 開啟(記得用有支援 UTF-8 的編輯器)
  3. 將檔案內所有的
    「DEFAULT CHARSET=latin1」
    改為
    「DEFAULT CHARSET=utf8」
  4. 將檔案內所有的
    「COLLATE=latin1_bin」
    改為
    「COLLATE=utf8_general_ci」
  5. 存檔
  6. 由 dreamhost 的 panel 新建立一個 databse
  7. 將此新建的 database 「校對」改為 utf8_general_ci
    (phpmysqladmin 此選項在點了資料庫後的「管理」內)
  8. 使用 phpmyadmin 的「載入」功能將您的 .sql 檔案載入
  9. 更改 wordpress/wp-config.php 內新資料庫的名稱
    (因為 dreamhost 不允許 user 於 phpmyadmin 改資料庫名字)

以上便大功告成!
若您用瀏覽器開啟 blog 後發現都是亂碼﹐請照下面步驟

  1. 開啟 wordpress/wp-include/wp-db.php
  2. 找尋「$this->dbh = @mysql_connect($dbhost, $dbuser, $dbpassword);」
  3. 在此行下面加上
    「$this->query("SET NAMES 'utf8'");」(注意別加上引號了)

這樣應該是能解決囉 :-)

目前有 1 個回應, 沒有引用

Mike 回應此篇文章 於 2009, 10月 21

網路爬了很多文章,才尋找到您的,感謝分享.

不過,再請教一下,我之前用 phpmyadmin 將所有的 Collation 都改成 utf8_unicode_ci,我也試過改成 utf8_general_ci,但我的文章標籤還是出現亂碼,加入時還正確,但一刊登就錯了,文章 Title 、內文、摘要 都正確,可否拜託指點一下,感謝感謝.

想要留言嗎?