1. 程式人生 > >修改WP安裝路徑及資料庫名稱

修改WP安裝路徑及資料庫名稱


  這幾天把WP由2.3.2升級到了2.5,效能上還是有些許的提升的,而且操作更加順手了,越來越喜歡這個小巧卻強大的程式了!
  不過,原來的WP安裝路徑為G:/pub/html,資料庫名稱為html,現在想把它們改成G:/pub/blog和blog。結果花了我一點時間。
  首先,把G:/pub/html目錄改名為G:/pub/blog,在phpmyadmin裡把資料庫名稱改名為blog及其相應的使用者許可權,把所有表的字首由原來的“html_”改為“blog_”,在blog資料庫裡把blog_options表中的siteurl和home都改為http://wind/blog,再修改WP新安裝目錄G:/pub/blog下的wp-config.php檔案,使用新的DB_NAME、DB_USER,並且把table_prefix由原來的“html_”改為新的“blog_”,相關修改如下:

// ** MySQL settings ** //
define('DB_NAME'
, 'blog');    // The name of the database
define('DB_USER', 'bloguser');     // Your MySQL username
......

// You can have multiple installations in one database if you give each a unique prefix
$table_prefix  
= 'blog_';   // Only numbers, letters, and underscores please!

  現在似乎可以訪問WP網站了,可是使用原管理員身份登入的時候卻出錯了!為什麼呢?我想是某個內部連結存在問題,而且資料應該保留在MySQL資料庫裡,於是在phpmyadmin裡搜尋整個blog資料庫,關鍵詞為“html”,發現blog_options表裡dashboard_widget_options的值中存在原來路徑的一些資訊,於是將相關的“html”更改為“blog”。重新使用管理員身份登入WP後臺管理,一切正常!
  (注:我是在公司局域網裡架設的伺服器,主機域名為http://wind/,www根目錄為G:/pub。WinXP下Apache2/Lighttpd+PHP5+MySQL5做伺服器。Lighttpd使用FastCGI。)