Thanks so much for that help. Loving Local too.
Thanks so much for that help. Loving Local too.
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.
Thanks for the workaround @jkiley!
Thank you so much this worked perfectly.
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.
Hey @gabkdlly and all –
This issue should be fixed with the most recent release of Local,
Can you try installing the latest version and verify that everything is working on your end?
Yes, I can confirm that this seems to be fixed in 5.6.8, thanks!
Nope, problem still persist on my Mac.
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Interesting @jpozivil – It looks like you’re on Catalina like me. Couple of other questions:
wpcliinstalled within your regular
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
which wp on the shell session started from the local returns
Thanks for that info!
All of that sounds similar to what I have. Here’s what my terminal startup looks like:
Looking at your screenshot, the main differences I see are:
/bin/zsh, yours is
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
Given all of that, can you answer a few 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?
Testing to see if you are getting a non-zero exit code, can you enter this in the terminal and let me know how it goes:
Also can you test manually running that site’s script from a running terminal? So looking at your screenshot, open a new terminal and run:
Leaving this here – I tried also switching to the basic Bash shell
chsh -s /bin/bash
and then open a shell from Local. I didn’t get a non-zero exit code.
That may all be a red herring, since my ZSH instance is still able to work, but maybe it helps zero in on something happening on your end.
Here’s my .zshrc screenshot. Nothing too unusual, I’d say.
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.
zshbinary is in a different location – can you tell me how you originally installed zsh?
echo $?results in
$ ~/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 ...
I’ve had a colleague with a Mac, but a different set up, to try it out too; and it does not work either.
Do you and your colleague have MySQL installed manually on the computer outside of Local? For example, installed using something like
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.
I’ll try to follow this https://stackoverflow.com/a/21422630/1337386
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?
sourcethat shell script
$PATHagain, 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.
$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:
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?
It seems to make no difference whether I have the
wp-cli “Oh my zsh” plugin in .zshrc or not.