Skip to content

Provide options for DB user/password #76

@lucrus73

Description

@lucrus73

I'm not sure if this is my fault, maybe I've simply failed at understanding the docs.

I need to export the database:

$ wp db export
mysqldump: Got error: 1044: "Access denied for user 'myuser'@'localhost' to database 'mydb'" when using LOCK TABLES

This is actually expected in my case, because I don't want to give the user that WP uses to connect to the database the LOCK TABLES privilege.

However I need the "wp db export" command to work when manually invoked from time to time.
I'm ok with manually specifying different username and password, using the "--<field>=<value>" syntax, but that fails too:

$ wp db export --user=root --password=mypass
mysqldump: Got error: 1045: "Access denied for user 'myuser'@'localhost' (using password: YES)" when trying to connect

which means wp cli handed only the "--password" option to mysqldump, but not the "--user" option. That's expected too, because the "--user" option is a global option that's used to specify the WordPress user, not the database user.

However I couldn't find any "--dbuser" or similar option: I'm not sure if that's by design or a missing feature, but I think it would make sense to have it in the latter case.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions