Wp db (WP-CLI)

Uit De Vliegende Brigade
Naar navigatie springen Naar zoeken springen

wp db doet dingen met databases, zoals uitvoeren van SQL-commando's

$ wp help db

NAME

  wp db

DESCRIPTION

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

SYNOPSIS

  wp db <command>

SUBCOMMANDS

  check         Checks the current status of the database.
  clean         Removes all tables with `$table_prefix` from the database.
  cli           Opens a MySQL console using credentials from wp-config.php
  columns       Displays information about a given table.
  create        Creates a new database.
  drop          Deletes the existing database.
  export        Exports the database to a file or to STDOUT.
  import        Imports a database from a file or from STDIN.
  optimize      Optimizes the database.
  prefix        Displays the database table prefix.
  query         Executes a SQL query against the database.
  repair        Repairs the database.
  reset         Removes all tables from the database.
  search        Finds a string in the database.
  size          Displays the database name and size.
  tables        Lists the database tables.

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