Closed electricarts closed 6 years ago
Hello @electricarts ,
I fear that you'll get the same error also simply trying to issue wp help
from inside your project :(
Unfortunately that should really means that wp-cli can't connect to the database; but keep in mind that Wordmove does nothing to configure wp-cli, so wp-cli must work on its own. Moreover - usually - when wp-cli can't connect to the database, neither WordPress can; have you tried to reach WordPress and see what it tells?
I'd try to compare your wp-config.php
db credentials against the ones you wrote in movefile.yml
.
Hi @pioneerskies,
the credentials are correct and the same. How could it work with the default sql_adapter without any problems when the credentials would be different in wp-config.php and movefile?
default
totally bypasses and ignores wordpress, thus not reading wp-config.php
configurations and relying only on the movefile.yml
.
wp-cli
has its standalone connection. I'd like to have faith in wp-cli
working when WordPress is working...but, my bad: can't figure out what's up there. Is actually WordPress working? Just one sure thing: connection between wp-cli
and the database is not managed by wordmove
; I suggest to troubleshoot wp-cli
alone before to retry with wordmove
:(
Other wp
commands? What are they saying?
A probably stupid question: Does wp-cli have to be installed on the live server (shared hosting) too? Sorry for this question, but I'm more of a pixel pusher than the server admin. ;-)
No, @electricarts , you need wp-cli locally only. Wordmove will manage to do search-replace
locally in any case.
I found out what I did wrong. I use MAMP (Pro) and of course I have to tell wp-cli which PHP version is used and where to find it. Otherwise wp-cli tries to access the Mac's PHP installation and not the MAMP PHP installation.
So for everyone who may have the same problem: I have added the following entries to my .bash_profile (~/.bash_profile):
export PATH=/Applications/MAMP/Library/bin:$PATH
PHP_VERSION=ls /Applications/MAMP/bin/php/ | sort -n | tail -1
export PATH=/Applications/MAMP/bin/php/${PHP_VERSION}/bin:$PATH
Restart the Terminal and everything works like a charm.
Found the solution here: https://wordpress.stackexchange.com/questions/235483/mamp-pro-wp-cli-error-error-establishing-a-database-connection
Thanks @electricarts for you precious feedback.
I've updated our MAMP dedicated wiki page with PHP_VERSION
part.
Could we thus close this issue?
Hi @pioneerskies, of course we can close this issue. Actually, it wasn't an issue. It was my unknowingness. ;-)
TLDR; Currently lacking sleep, might be wrong: WPCLI relying on wp-config.php
not cool, prefer to rely on movefile.yml
Apologies for resurrecting this bug, but I have the same issue for different reasons. I think requiring WPCLI might be shortsighted (or perhaps I am 🤔 ). I serve all of my local WP sites from tools such as Vagrant with local drives aliased for Vagrant to read/serve as needed. However, this inherently means that my wp-config.php
isn't locally relevant and therefore isn't useful to WPCLI. Now, I could vagrant ssh
into my instance whenever I wanted to deploy, but that seems like a hassle.
At the very least, it would be nice if wordmove
could forward relevant db values to WPCLI.
Hello @humblecoder ,
I think you should open a new discussion or a feature request if you have a clear vision on how the things could work for you.
Some notes:
wordmove
is not build specifically for vagrant. It's built to be run locally. The "local" could be your workstation, a CI, a docker machine, a vagrant box, a remote VPS... We don't know what your local environment is and we consider it should be up to youwp-config.php
isn't locally relevant, but I fear it is relevant for wp-cli
. Taking a look at the wp-cli
's manual I can't see how to pass database connection configurations, but ...wp-cli
do support vagrant, feature explicitly thought to remove the manual vagrant ssh
operation It can also easily utilize Vagrant’s ssh helper command to figure out the SSH parameters, by piping the WP-CLI command to vagrant ssh using the vagrant scheme like --ssh=vagrant:default where default is the Vagrant machine name/id, or if defined as an alias like the examples below. Some Vagrant boxes ship this by default so you can use WP-CLI from the host machine out-of-the-box.
Looking forward to read your new issue ;)
I can't push or pull databases when using wpcli as sql_adapter as "global" entry in movefile.yml. The error message says: Error when establishing a database connection. Username or password are incorrect or the database server at localhost can't be reached. (translated from german).
The wordmove doctor shows everything green. Updated to the latest wp-cli version (1.5.1)
When using "default" as sql_adapter everything works like a charm! So i don't know whats wrong when using the wpcli sql_adapter.