A command line interface for WordPress

Commands » db

wp db - Perform basic database operations using credentials stored in wp-config.php

Quick links: Github issues


# Create a new database.
$ wp db create
Success: Database created.

# Drop an existing database.
$ wp db drop --yes
Success: Database dropped.

# Reset the current database.
$ wp db reset --yes
Success: Database reset.

# Execute a SQL query stored in a file.
$ wp db query < debug.sql


Name Description
check Check the current status of the database.
cli Open a MySQL console using credentials from wp-config.php
create Create a new database.
drop Delete the existing database.
export Exports the database to a file or to STDOUT.
import Import a database from a file or from STDIN.
optimize Optimize the database.
query Execute a SQL query against the database.
repair Repair the database.
reset Remove all tables from the database.
tables List the database tables.