Closed Muffinman closed 4 years ago
@Muffinman This will be fixed in the next release via #157 through the addition of a --defaults
flag which counters the default --no-defaults
behavior. This behavior is still the default, though, for backwards compatibility reasons.
I'm also having this problem with other commands
wp db query "SHOW TABLES;"
wp db query "SHOW TABLES;" --defaults
!Also gives an errorwp db reset --yes
wp db clean --yes
wp db drop --yes
Also see the localWP thread
@janw-me I assume this is a duplicate of https://github.com/wp-cli/db-command/issues/185. I started fixing it via https://github.com/wp-cli/db-command/pull/206 but was slowed down because I hit a bug in WP core (https://core.trac.wordpress.org/ticket/53830).
Ahh yes this is exactly the same.
Bug Report
Describe the current, buggy behavior
On my macOS system, I have MySQL set up to listen at /usr/local/var/mysql/mysql.sock. I have this correctly configured in my php.ini and mysql server/client config files so that everything works as normal.
For some reason, the
wp db
command seems to have the--no-defaults
flag so all mysql client settings are ignored. This causes allwp db
commands to fail as it falls back to the old socket path at the time MySQL was compiled.I'm wondering what the thought process was behind this flag? As far as I know the defaults can be easily overridden by specifying the flags, so I can't see what purpose this has. I found the commits where this was added, but no mention of why.
https://github.com/wp-cli/db-command/commit/4fb859972901bef44a03c491316fa721b65b624e https://github.com/wp-cli/db-command/commit/0bcaa756c60e55dc04ff42e09461ad3540325952
Describe how other contributors can replicate this bug
wp db import
orwp db export
Example
Describe what you would expect as the correct outcome
The
wp db
command should correctly pick up the default socket path from the PHP ini or default MySQL client settings.Let us know what environment you are running this on
Provide a possible solution
Remove
--no-defaults
from mysql commands, or attempt to fetch socket path from PHP / MySQL.