Applies to: WordPress

WordPress 說明

我們已盡最大努力為您翻譯本頁面。 我們也有提供英文頁面。

使用WP-CLI匯出及匯出資料庫

WP-CLI是一個命令行工具,可協助您在WordPress網站上執行各種動作。如果您熟悉使用SSH命令,您會注意到WP-CLI簡化了為WordPress網站建立的命令。以下是您可以如何使用WP-CLI的資料庫匯出及匯入指令。

須注意事項:若要完成以下步驟,您將需擁有下列內容:
Note: If you have a VPS or DED Server, you need to install WP-CLI before you can start using it. WP-CLI is not available on our Windows Hosting (Plesk) plans.

使用WP-CLI匯出資料庫

  1. 使用SSH連接至您的主機帳戶
  2. 使用bash命令ls列出檔案與資料夾,使用cd../在目錄間移動,直到您進入WordPress檔案的目錄。
  3. 輸入以下命令:
    wp db export filename.sql
    • 在上方的指令中,您應該用您要用的備份檔案名稱來取代filename.sql

匯出完成後,系統即會顯示成功訊息。較大的資料庫需要較長時間匯出。

Note: Web Hosting (cPanel) and Web Hosting Plus users may experience the following error:
mysqldump: Error: 'Access denied; you need (at least one of) the PROCESS privilege(s) for this operation' when trying to dump tablespaces
In most cases, your database will have been exported successfully, despite seeing this error. But we recommend confirming the export by checking your database tables manually.

使用WP-CLI匯入資料庫

  1. 使用FTP檔案管理員將SQL備份檔案上傳至包含WordPress檔案的資料夾。
  2. 使用SSH連接至您的主機帳戶
  3. 使用bash命令ls列出檔案與資料夾,使用cd../在目錄間移動,直到您進入WordPress檔案的目錄。
  4. 輸入以下命令:
    wp dbimport filename.sql
    • 在上面的命令中,您應該用備份檔案的實際名稱來取代filename.sql

匯入完成後,系統即會顯示成功訊息。較大的資料庫需要較長時間匯入。

更多資訊

  1. 如果您的伺服器沒有可用的WP-CLI,您可以使用標準的SSH指令來匯出匯入資料庫。
  2. 您也可以在phpMyAdmin中匯出匯入資料庫。
  3. 尋找並取代SSH的WordPress