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=<value>]:
Password:
Success: Created database user 'appuser'@'localhost' with all privileges on 'wp_database'.
Subcommands
| Name | Description |
|---|---|
| wp db users create | Creates a database user. |