Local 5.2.4 : Can't connect to local MySQL server through socket (macOS)

Hi,

i’m under macOS Catalina ( 10.15.3 ) and i can’t use “wp db reset” but “wp db search test” work…

So i removed all data of Local ( in “Application support/Local” and “Application” ) and re-install everything. Now i got a fresh install of Local 5.2.4.

I create a new site, open site shell and having the same issue.

Could you please help me out with that?

@clay any update on that? Its really important to use some WP CLI features. I got this same error with latest version 5.2.5

Same issue here:

JiveDig@JiveDigs-MBP ~ % /Users/JiveDig/Library/Application\ Support/Local/ssh-entry/8xa0al5vx.sh; exit
-n -e
Setting Local environment variables...
----
WP-CLI: WP-CLI 2.4.0
PHP:    7.3.5
MySQL:  mysql  Ver 14.14 Distrib 5.7.28, for macos10.14 (x86_64) using  EditLine wrapper
----
Launching shell: /bin/zsh ...
JiveDig@JiveDigs-MBP public % wp db export
mysqldump: Got error: 2002: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) when trying to connect

Running Local 5.2.5, but it happened on the prior version of v5 as well.

I hope this bug will be fix in 5.2.6 :S

Does this work?

still not workibng even in new version Local 5.2.7 :S @clay

This seems to work.

SOCKET=$(mysqld --verbose --help | grep ^socket | awk '{print $2, $3, $4}');ln -sv $SOCKET /tmp/mysql.sock

I tried but didn’t work for me, sadly.

What did the results of the command show?

I’m getting the follow @afragen:

----
WP-CLI: WP-CLI 2.4.0
PHP:    7.3.5
MySQL:  mysql  Ver 8.0.16 for macos10.14 on x86_64 (MySQL Community Server - GPL)
----
Launching shell: /bin/zsh ...

wp101/app/public via 🐘 v7.3.5 
➜ wp db check
mysqlcheck: Got error: 1045: Access denied for user 'root'@'localhost' (using password: YES) when trying to connect

wp101/app/public via 🐘 v7.3.5 
➜ SOCKET=$(mysqld --verbose --help | grep ^socket | awk '{print $2, $3, $4}');ln -sv $SOCKET /tmp/mysql.sock
2020-04-18T19:01:27.759745Z 0 [ERROR] unknown variable 'mysqlx=0'
2020-04-18T19:01:27.766107Z 0 [ERROR] Aborting

Gotta say I’m not sure. You’re starting off with a different error.

Also not sure why the command appears half commented out.

1 Like

No worries, @afragen, thanks for being there :smiley:. I think it’s just the markdown formatting for the code that’s making it appear commented out.

1 Like

I was finally able to resolve this with a solution on this post Unable to run Db Export via CLI

don’t know how i missed this earlier but the --socket argument after my wp cli db command totally works.

1 Like

Although SOCKET=$(mysqld --verbose --help | grep ^socket | awk '{print $2, $3, $4}');ln -sv $SOCKET /tmp/mysql.sock echos the socket correctly and saves as a variable but the wp db export doesn’t work as it should out of the box nor with --socket="${SOCKET}"

However, if I manually insert --socket then this works:

wp db export wp-content/plugins/my-plugin/tests/_data/dump.sql --socket="/Users/cliff/Library/Application Support/Local/run/oQ5Apb3x2/mysql/mysqld.sock"

So, thankfully, this workaround exists, but this should definitely be fixed :slight_smile:

1 Like

The --socket solutions and symlinking of the sockets didn’t work so I tried this:

I had a mysql installed through Homebrew. After deleting that one, just reinstalled Local and all went well.

Hope it stays this way :wink:

Ciao!

The --socket workout seems to only work when doing export/import commands. At least for me. I can’t reset the database via WP CLI

find this solution for one line command db reset

mysql -Nse 'show tables' local | while read table; do mysql -e "drop table $table" local; done```

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