使用WP-CLI匯出及匯出資料庫
WP-CLI是一個命令行工具,可協助您在WordPress網站上執行各種動作。如果您熟悉使用SSH命令,您會注意到WP-CLI簡化了為WordPress網站建立的命令。以下是您可以如何使用WP-CLI的資料庫匯出及匯入指令。
須注意事項:若要完成以下步驟,您將需擁有下列內容:
- SSH應用程式。我們建議使用Windows的PuTTY ,或MacOS的終端。
- 您的 FTP 詳細資訊。如果您並未把 FTP 主機、使用者名稱及密碼記在紙上,請去查看這些資訊:
- FTP 主機可用網域名稱或 IP 位址。
- 前往主機服務帳戶,即可查看 Web Hosting (cPanel) 或 Managed Hosting for WordPress (步驟 1-7) 的 FTP 使用者名稱和密碼。
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匯出資料庫
- 使用SSH連接至您的主機帳戶。
- 使用bash命令ls列出檔案與資料夾,使用cd及../在目錄間移動,直到您進入WordPress檔案的目錄。
- 輸入以下命令:
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 tablespacesIn 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匯入資料庫
- 使用FTP或檔案管理員將SQL備份檔案上傳至包含WordPress檔案的資料夾。
- 使用SSH連接至您的主機帳戶。
- 使用bash命令ls列出檔案與資料夾,使用cd及../在目錄間移動,直到您進入WordPress檔案的目錄。
- 輸入以下命令:
wp dbimport filename.sql
- 在上面的命令中,您應該用備份檔案的實際名稱來取代filename.sql 。
匯入完成後,系統即會顯示成功訊息。較大的資料庫需要較長時間匯入。
更多資訊
- 如果您的伺服器沒有可用的WP-CLI,您可以使用標準的SSH指令來匯出和匯入資料庫。
- 您也可以在phpMyAdmin中匯出和匯入資料庫。
- 尋找並取代SSH的WordPress