wp db users <command>

Manages MySQL and MariaDB user accounts.

In this article

Unless overridden, these commands run on the after_wp_config_load hook, after wp-config.php has been loaded into scope. Available since WP-CLI 3.0.0. Creating users needs a database account with the CREATE USER privilege (and GRANT OPTION for --grant-privileges), which the one in wp-config.php usually doesn’t have. Pass a privileged account with --dbuser and --dbpass.

Examples

# Create a user with full privileges on the WordPress database, prompting for both passwords.
$ wp db users create appuser localhost --grant-privileges --dbuser=root --prompt=dbpass
1/1 [--dbpass=&lt;value&gt;]:
Password:
Success: Created database user 'appuser'@'localhost' with all privileges on 'wp_database'.

Subcommands

NameDescription
wp db users create

Creates a database user.

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.