How to Export a Database Using WP-CLI

How to Export a Database Using WP-CLI

Using WP-CLI can make managing your website easier, even when performing backups or exporting databases, which is what this tutorial will cover.

If WP-CLI is not yet installed on your server, you can install it first by following this tutorial: How to Install WP-CLI on Linux.

Once you have confirmed it is installed, you can begin with the first step.

1. SSH Login

If you are using a VPS, you can first log in via SSH using an application such as PuTTY or you can also use CMD or Terminal with this command

  • root: the username to log in to the server
  • 192.168.1.1: the server IP you are using
  • 22: the default SSH port. If you are using a different port, you can change it to match the port you are using

2. Open the WordPress Installation Folder

To run wp-cli, you can first open your WordPress installation folder, for example in public_html

cd public_html

3. Export Database

Now you can export the database, and the database file will be saved in your WordPress installation folder

wp db export database.sql
  • change database.sql to the name of the database file you want to save

After the export process is successful, you will receive a success message like Success: Exported to ‘database.sql’. and you can check your WordPress installation folder to download the exported .sql file.

Written by

Muhammad Khoirun Nasikin

I enjoy tinkering with WordPress, hosting, VPS, web development, and various small experiments related to websites. I have over 3 years of experience in the web hosting industry.

COMMENTS

Loading...