Cool, that works! Yay! Is there any way of getting the SQL socket address programmatically? I’ve got 3 or 4 users on different platforms (Linux/Mac) and each has different .../run/??????/mysqld.sock – which means I can’t create a universal script for all the users.
This seems like a bug. the workaround above works, but it should use the socket automatically. @clay and team, is there something I’m missing here? I am on the 5.1 beta and got that error.
this helped me a lot. thank you! i haven’t been able to use the site shell to do wp cli stuff on the local database ever since i upgraded to Lightning. it’s not ideal but it definitely works using the --socket argument
This still seems to be an issue on version 5.6.6 of Local. To me, the proper fix seems to be to set the MYSQL_UNIX_PORT environment variable together with the other ones that get set when a site shell is opened.
I’m on Catalina, using iTerm with zshell as my terminal. I don’t have wpcli installed other than what comes with Local and it’s not in my regular $PATH.
Looking at your screenshot, the main differences I see are:
Different oh-my-zsh theme
Different shell path (mine is /bin/zsh, yours is /usr/local/bin/zsh)
Different “Last login” tty
My prompt shows a red number which is the exit code of the last command. (the [1] in my screenshot) I wonder if there’s a bug that my terminal is just passing over, while your terminal isn’t working.
Maybe there’s something going on with how zsh is configured too. Do you have your dotfiles somewhere public that I can take a look at?
Here’s a screenshot of what I have for zsh config:
As well as a link to my dotfiles in case you want to take a look (though typical disclaimer, I need to cleanup the zsh starttime as well as all the things that are piled onto my $PATH)
The theme I use displays a red at the beginning of the prompt for a non-zero error codes. So, I’m don’t think, I’m getting any error 1 there.
To answer your questions.
Since the big thing that stands out to me is that the zsh binary is in a different location – can you tell me how you originally installed zsh?
I can’t really remember but I believe I used brew
echo $? results in 0
Running the script from a new terminal results in no error:
$ ~/Library/Application\ Support/Local/ssh-entry/1ULnAY_XV.sh
-n -e
Setting Local environment variables...
----
WP-CLI: WP-CLI 2.5.0-alpha
Composer: 1.10.8 2020-06-24
PHP: 7.3.5
MySQL: mysql Ver 8.0.16 for macos10.14 on x86_64 (MySQL Community Server - GPL)
----
Launching shell: /usr/local/bin/zsh ...
Funnily enough, if I try to run mysql, I get the same error message. I don’t recall installing MySQL. I’ve got a feeling that MacOS comes with MySQL preinstalled, but it’s not running by default.