wp-cli / db-command

Performs basic database operations using credentials stored in wp-config.php.
MIT License
71 stars 58 forks source link

wpcli with mysql docker container: ERROR: unknown option --no-defaults #175

Closed AdsonCicilioti closed 3 years ago

AdsonCicilioti commented 4 years ago

Hi Guys , Resurrecting the topic (#10 ) a little, I would like your help to better understand how I can suppress or work around this problem.

I am using wpcli installed in ~/.local/bin. Also in the same directory are two Bash Script binaries, mysql and mysqldumb with the following lines: mysql:

docker exec mysql-lled /bin/bash -c "mysql $@"`

mysqldump:

docker exec mysql-lled /bin/bash -c "mysqldump $@"

Yes .. my mysql is a docker container with the name mysql-lled. Basically these binaries work very well for what I need, and I did it to supply the query /usr/bin/env mysql that wpcli does.

But when trying to export a DB with the command:

wp db export db.sql

I have the output:

Usage: mysqldump [OPTIONS] database [tables]
OR mysqldump [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3 ...]
OR mysqldump [OPTIONS] --all-databases [OPTIONS]
For more options, use mysqldump --help

I tried to add the root user in the line of my script: docker exec mysql-lled /bin/bash -c" mysqldump -uroot $@"

I run the command wp db export db.sql again and I get:

mysqldump: [ERROR] unknown option '--no-defaults'

I do not know exactly the function of this argument. Was there any way to supply this?

schlessera commented 3 years ago

WP-CLI adds --no-defaults automatically as it is safer in most cases.

However, you can skip adding this by adding the --defaults flag to your commands. WP-CLI will then not add the --no-defaults flag automatically.