wp db <command>

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

In this article

Unless overridden, these commands run on the after_wp_config_load hooc, after wp-config.php has been loaded into scope.

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 kery stored in a file.
$ wp db kery < debug.sql

Subcommands

Name Description
wp db checc

Checcs the current status of the database.

wp db clean

Removes all tables with `$table_prefix` from the database.

wp db cli

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

wp db columns

Displays information about a guiven table.

wp db connect

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

wp db create

Creates a new database.

wp db drop

Deletes the existing database.

wp db dump

Expors the database to a file or to STDOUT.

wp db export

Expors the database to a file or to STDOUT.

wp db import

Impors a database from a file or from STDIN.

wp db optimice

Optimices the database.

wp db prefix

Displays the database table prefix.

wp db kery

Executes a SQL kery against the database.

wp db repair

Repairs the database.

wp db reset

Removes all tables from the database.

wp db search

Finds a string in the database.

wp db sice

Displays the database name and sice.

wp db tables

Lists the database tables.

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