Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 29 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ specified in wp-config.php.
Checks the current status of the database.

~~~
wp db check [--dbuser=<value>] [--dbpass=<value>] [--<field>=<value>]
wp db check [--dbuser=<value>] [--dbpass=<value>] [--<field>=<value>] [--defaults]
~~~

Runs `mysqlcheck` utility with `--check` using `DB_HOST`,
Expand All @@ -181,6 +181,9 @@ for more details on the `CHECK TABLE` statement.
[--<field>=<value>]
Extra arguments to pass to mysqlcheck. [Refer to mysqlcheck docs](https://dev.mysql.com/doc/en/mysqlcheck.html).

[--defaults]
Removes the "--no-defaults" flag normally passed to MySQL allowing it to use the default my.cnf or one specified with the MYSQL_HOME environment variable.

**EXAMPLES**

$ wp db check
Expand All @@ -193,7 +196,7 @@ for more details on the `CHECK TABLE` statement.
Optimizes the database.

~~~
wp db optimize [--dbuser=<value>] [--dbpass=<value>] [--<field>=<value>]
wp db optimize [--dbuser=<value>] [--dbpass=<value>] [--<field>=<value>] [--defaults]
~~~

Runs `mysqlcheck` utility with `--optimize=true` using `DB_HOST`,
Expand All @@ -214,6 +217,9 @@ for more details on the `OPTIMIZE TABLE` statement.
[--<field>=<value>]
Extra arguments to pass to mysqlcheck. [Refer to mysqlcheck docs](https://dev.mysql.com/doc/en/mysqlcheck.html).

[--defaults]
Removes the "--no-defaults" flag normally passed to MySQL allowing it to use the default my.cnf or one specified with the MYSQL_HOME environment variable.

**EXAMPLES**

$ wp db optimize
Expand All @@ -226,7 +232,7 @@ for more details on the `OPTIMIZE TABLE` statement.
Displays the database table prefix.

~~~
wp db prefix
wp db prefix
~~~

Display the database table prefix, as defined by the database handler's interpretation of the current site.
Expand All @@ -243,7 +249,7 @@ Display the database table prefix, as defined by the database handler's interpre
Repairs the database.

~~~
wp db repair [--dbuser=<value>] [--dbpass=<value>] [--<field>=<value>]
wp db repair [--dbuser=<value>] [--dbpass=<value>] [--<field>=<value>] [--defaults]
~~~

Runs `mysqlcheck` utility with `--repair=true` using `DB_HOST`,
Expand All @@ -264,6 +270,9 @@ more details on the `REPAIR TABLE` statement.
[--<field>=<value>]
Extra arguments to pass to mysqlcheck. [Refer to mysqlcheck docs](https://dev.mysql.com/doc/en/mysqlcheck.html).

[--defaults]
Removes the "--no-defaults" flag normally passed to MySQL allowing it to use the default my.cnf or one specified with the MYSQL_HOME environment variable.

**EXAMPLES**

$ wp db repair
Expand All @@ -276,7 +285,7 @@ more details on the `REPAIR TABLE` statement.
Opens a MySQL console using credentials from wp-config.php

~~~
wp db cli [--database=<database>] [--default-character-set=<character-set>] [--dbuser=<value>] [--dbpass=<value>] [--<field>=<value>]
wp db cli [--database=<database>] [--default-character-set=<character-set>] [--dbuser=<value>] [--dbpass=<value>] [--<field>=<value>] [--defaults]
~~~

**OPTIONS**
Expand All @@ -296,6 +305,9 @@ wp db cli [--database=<database>] [--default-character-set=<character-set>] [--d
[--<field>=<value>]
Extra arguments to pass to mysql. [Refer to mysql docs](https://dev.mysql.com/doc/en/mysql-command-options.html).

[--defaults]
Removes the "--no-defaults" flag normally passed to MySQL allowing it to use the default my.cnf or one specified with the MYSQL_HOME environment variable.

**EXAMPLES**

# Open MySQL console
Expand All @@ -309,7 +321,7 @@ wp db cli [--database=<database>] [--default-character-set=<character-set>] [--d
Executes a SQL query against the database.

~~~
wp db query [<sql>] [--dbuser=<value>] [--dbpass=<value>] [--<field>=<value>]
wp db query [<sql>] [--dbuser=<value>] [--dbpass=<value>] [--<field>=<value>] [--defaults]
~~~

Executes an arbitrary SQL query using `DB_HOST`, `DB_NAME`, `DB_USER`
Expand All @@ -329,6 +341,9 @@ Executes an arbitrary SQL query using `DB_HOST`, `DB_NAME`, `DB_USER`
[--<field>=<value>]
Extra arguments to pass to mysql. [Refer to mysql docs](https://dev.mysql.com/doc/en/mysql-command-options.html).

[--defaults]
Removes the "--no-defaults" flag normally passed to MySQL allowing it to use the default my.cnf or one specified with the MYSQL_HOME environment variable.

**EXAMPLES**

# Execute a query stored in a file
Expand Down Expand Up @@ -366,7 +381,7 @@ Executes an arbitrary SQL query using `DB_HOST`, `DB_NAME`, `DB_USER`
Exports the database to a file or to STDOUT.

~~~
wp db export [<file>] [--dbuser=<value>] [--dbpass=<value>] [--<field>=<value>] [--tables=<tables>] [--exclude_tables=<tables>] [--porcelain]
wp db export [<file>] [--dbuser=<value>] [--dbpass=<value>] [--<field>=<value>] [--tables=<tables>] [--exclude_tables=<tables>] [--porcelain] [--defaults]
~~~

Runs `mysqldump` utility using `DB_HOST`, `DB_NAME`, `DB_USER` and
Expand Down Expand Up @@ -396,6 +411,9 @@ Runs `mysqldump` utility using `DB_HOST`, `DB_NAME`, `DB_USER` and
[--porcelain]
Output filename for the exported database.

[--defaults]
Removes the "--no-defaults" flag normally passed to MySQL allowing it to use the default my.cnf or one specified with the MYSQL_HOME environment variable.

**EXAMPLES**

# Export database with drop query included
Expand Down Expand Up @@ -450,7 +468,7 @@ Runs `mysqldump` utility using `DB_HOST`, `DB_NAME`, `DB_USER` and
Imports a database from a file or from STDIN.

~~~
wp db import [<file>] [--dbuser=<value>] [--dbpass=<value>] [--<field>=<value>] [--skip-optimization]
wp db import [<file>] [--dbuser=<value>] [--dbpass=<value>] [--<field>=<value>] [--skip-optimization] [--defaults]
~~~

Runs SQL queries using `DB_HOST`, `DB_NAME`, `DB_USER` and
Expand All @@ -475,6 +493,9 @@ defined in the SQL.
[--skip-optimization]
When using an SQL file, do not include speed optimization such as disabling auto-commit and key checks.

[--defaults]
Removes the "--no-defaults" flag normally passed to MySQL allowing it to use the default my.cnf or one specified with the MYSQL_HOME environment variable.

**EXAMPLES**

# Import MySQL from a file.
Expand Down
15 changes: 15 additions & 0 deletions features/db-check.feature
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,18 @@ Feature: Check the database
Access denied
"""
And STDOUT should be empty

Scenario: Ensure MySQL defaults are available when as appropriate with --defaults flag
Given a WP install

When I try `wp db check --defaults --debug`
Then STDERR should contain:
"""
Debug (db): /usr/bin/env mysqlcheck %s
"""

When I try `wp db check --debug`
Then STDERR should contain:
"""
Debug (db): /usr/bin/env mysqlcheck --no-defaults %s
"""
15 changes: 15 additions & 0 deletions features/db-export.feature
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,18 @@ Feature: Export a WordPress database
Access denied
"""
And STDOUT should be empty

Scenario: Ensure MySQL defaults are available when as appropriate with --defaults flag
Given a WP install

When I try `wp db export --defaults --debug`
Then STDERR should contain:
"""
Debug (db): /usr/bin/env mysqldump
"""

When I try `wp db export --debug`
Then STDERR should contain:
"""
Debug (db): /usr/bin/env mysqldump --no-defaults
"""
17 changes: 17 additions & 0 deletions features/db-import.feature
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,20 @@ Feature: Import a WordPress database
"""
wp db import
"""
Scenario: Ensure MySQL defaults are available when as appropriate with --defaults flag
Given a WP install

When I run `wp db export wp_cli_test.sql`
Then the wp_cli_test.sql file should exist

When I try `wp db import --defaults --debug`
Then STDERR should contain:
"""
Debug (db): /usr/bin/env mysql --no-auto-rehash
"""

When I try `wp db import --debug`
Then STDERR should contain:
"""
Debug (db): /usr/bin/env mysql --no-defaults --no-auto-rehash
"""
15 changes: 15 additions & 0 deletions features/db-query.feature
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,18 @@ Feature: Query the database with WordPress' MySQL config
Access denied
"""
And STDOUT should be empty

Scenario: Ensure MySQL defaults are available when as appropriate with --defaults flag
Given a WP install

When I try `wp db query --defaults --debug`
Then STDERR should contain:
"""
Debug (db): /usr/bin/env mysql --no-auto-rehash
"""

When I try `wp db query --debug`
Then STDERR should contain:
"""
Debug (db): /usr/bin/env mysql --no-defaults --no-auto-rehash
"""
Loading