Unable to run Db Export via CLI

Nice @jpozivil! I think that’s getting closer to the underlying issue!

For context, under the hood, Local is adjusting the $PATH and putting the various services (PHP, MySQL, NGINX/Apache) ahead of other things.

For my terminal, you can see that when opened through “Open Site Shell” the terminal session is using Local’s version of those binaries:

Given that your terminal is showing mysql as running from /usr/local/mysql/bin/mysql – I’m not sure that the linked StackOverflow answer would fix things in this case, since that answer would be starting the Host’s MySQL daemon, and not the MySQL daemon provided by Local.

What I think is happening is that Local’s MySQL binary isn’t being correctly added to your $PATH, or possibly something else (probably brew?) is adjusting the $PATH after Local has done so.

Can you try this and let me know what happens?

  1. Click “Open Site Shell”
  2. Echo the $PATH variable
  3. Leaving the current terminal open, edit the startup script. Comment out the last line of exec $SHELL
  4. source that shell script
  5. Echo the $PATH again, and try interacting with the db

I realize that’s probably a little confusing so hopefully this screenshot helps clarify:

I’ve tried after sourcing the modified start up script. Strange, I still get the same error.

When you echo the $PATH variable, do you see Local’s mysql binary in the path?

One other thing to note is that the startup script has two other bash variables that it is setting: $MYSQL_HOME and $WP_CLI_CONFIG_PATH

I notice that you are using the wp-cli “Oh my zsh” plugin – can you try temporarily commenting that out within the .zshrc file and see if that helps at all?

I do see the path for Local’s mysql /Applications/Local.app/Contents/Resources/extraResources/lightning-services/mysql-8.0.16+5/bin/darwin/bin, but then it gets over written by /usr/local/mysql/bin. Not quite sure how does that happen as in my .zshrc I’ve got PATH=export PATH=/usr/local/sbin:/usr/local/bin:$HOME/bin:$PATH. Surely that should add any existing string in the $PATH variable to the end.

export PATH=/usr/local/sbin:/usr/local/bin:$HOME/bin:$PATH /Users/jpozivil/Library/Application Support/Local/run/1ULnAY_XV/conf/mysql

Is it not a problem that the Application Support folder does not have the space character escaped?

$WP_CLI_CONFIG_PATH=/Applications/Local.app/Contents/Resources/extraResources/bin/wp-cli/config.yaml

It seems to make no difference whether I have the wp-cli “Oh my zsh” plugin in .zshrc or not.

From the sounds of things, this seems related to $PATH pollution from mysql. I know that this is something the we’re working on getting better at, but until those fixes are released, I wonder if there’s a workaround for you.

Since this appears to be related to mysql – how was mysql installed on the host computer? Did you use something like Homebrew?

To be honest, I can’t remember. I’ve checked Homebrew – brew list mysql – and it wasn’t that.

Adding another data point here. I’m on Windows 10 with Local v5.7.4+4876 and I’m experiencing the same issue where I can’t use WP-CLI to export a DB with both the git bash and cmd shells.

Setting Local environment variables...
----
WP-CLI:   WP-CLI 2.5.0-alpha
Composer: 1.10.1 2020-03-13
PHP:      7.3.5
MySQL:    C:\Program Files (x86)\Local\resources\extraResources\lightning-services\mariadb-10.4.10+4\bin\win32\bin\mysql.exe  Ver 15.1 Distrib 10.4.10-MariaDB, for Win32 (AMD64), source revision c24ec3cece6d8bf70dac7519b6fd397c464f7a82
----
Launching shell: /usr/bin/bash ...

user@COMPUTERMINGW64 /d/dev/local-sites/xxxxx/app/public
$ wp db export
mysqldump: Got error: 2002: "Can't connect to MySQL server on '192.168.95.100' (10060)" when trying to connect

image
image

Value of $PATH (formatted for readability)

/c/Program Files (x86)/Local/resources/extraResources/bin/composer/win32:
/c/Program Files (x86)/Local/resources/extraResources/bin/wp-cli/win32:
/c/Program Files (x86)/Local/resources/extraResources/lightning-services/php-7.3.5+10/bin/win64:
/c/Program Files (x86)/Local/resources/extraResources/lightning-services/mariadb-10.4.10+4/bin/win32/bin:
/c/Users/user1/bin:
/mingw64/bin:
/usr/local/bin:
/usr/bin:
/bin:
/mingw64/bin:
/usr/bin:
/c/Users/user1/bin:
/c/WINDOWS/System32:
/c/Program Files/Yori:
/c/Windows/system32:
/c/Windows:
/c/Windows/System32/Wbem:
/c/Windows/System32/WindowsPowerShell/v1.0:
/c/Windows/System32/OpenSSH:
/c/Program Files/Intel/WiFi/bin:
/c/Program Files/Common Files/Intel/WirelessCommon:
/c/Program Files/PuTTY:
/c/Program Files/WinMerge:
/c/Program Files (x86)/Windows Kits/10/Windows Performance Toolkit:
/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:
/d/dev/php:
/c/ProgramData/ComposerSetup/bin:
/c/Users/user1/AppData/Roaming/nvm:
/c/Program Files/nodejs:
/c/Program Files/TortoiseGit/bin:
/cmd:
/usr/bin:
/c/Program Files/dotnet:
/c/WINDOWS/system32:
/c/WINDOWS:
/c/WINDOWS/System32/Wbem:
/c/WINDOWS/System32/WindowsPowerShell/v1.0:
/c/WINDOWS/System32/OpenSSH:
/c/Program Files/NVIDIA Corporation/NVIDIA NvDLISR:
/c/Program Files/Yori:
/c/Users/user1/AppData/Local/Microsoft/WindowsApps:
/c/Program Files/Intel/WiFi/bin:
/c/Program Files/Common Files/Intel/WirelessCommon:
/c/Users/user1/AppData/Roaming/Composer/vendor/bin:
/c/Users/user1/AppData/Roaming/nvm:
/c/Program Files/nodejs:
/usr/bin/vendor_perl:
/usr/bin/core_perl

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.