wp db <command>

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

EXAMPLES EXAMPLES

# 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

Top ↑

SUBCOMMANDS SUBCOMMANDS

Name Description
wp db check

Check the current status of the database.

wp db cli

Open a MySQL console using credentials from wp-config.php

wp db create

Create a new database.

wp db drop

Delete the existing database.

wp db export

Exports the database to a file or to STDOUT.

wp db import

Import a database from a file or from STDIN.

wp db optimize

Optimize the database.

wp db prefix

Display the database table prefix.

wp db query

Execute a SQL query against the database.

wp db repair

Repair the database.

wp db reset

Remove all tables from the database.

wp db search

Find a string in the database.

wp db size

Display the database name and size.

wp db tables

List the database tables.

Command documentation is regenerated at every release. To add or update an example, please submit a pull request against the corresponding part of the codebase.