The wp db query
command fails with a permissions error under some configurations
#272
Open
2 tasks done
Bug Report
Describe the current, buggy behavior
While trying to run
wp db query
within a WordPress site in Local, I get the following error:The connection issue seems odd because I am able to successfully run
wp db cli
and interact with the WP database.Describe how other contributors can replicate this bug
This might be true under other environments, but using Local is probably the easiest place to reproduce:
wp db query
command, for examplewp db query 'show tables;'
wp db cli
and note you are able to connect to the DBDescribe what you would expect as the correct outcome
I would expect the
wp db query
command to work when otherwp db
commands workLet us know what environment you are running this on
Provide a possible solution
I think the issue might have to do with the inclusion of the
--no-defaults
flag when trying to determine the supported SQL modes:db-command/src/DB_Command.php
Lines 2122 to 2129 in 4cce2d5
I came to that conclusion by using
--debug
to find the actualmysql
command and then iterating on the various args. Notably, when I run the command for determining the SQL modes, it appears that it runs fine in my terminal without adjustments. However, if I try a different--execute=...
flag usingshow databases
as the query, I get different results. It seems like removing the--no-defaults
flag gets the command to actually see the WP site (ie, I can see thelocal
database in the output).See this gist with the full terminal output:
https://gist.github.com/bgturner/f4a8edf762d5b2e4f1740298d96b7434
I'm not quite sure what next steps to take or what additional debugging would help clarify the issue. Let me know what else I can do to help!
The text was updated successfully, but these errors were encountered: