Wp db reset -- Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

Bug Summary

When I try to run wp db reset in a terminal (using Open Site Shell) I get the error

Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

but wp db import and wp db export work as expected.

Steps to reproduce

Open the site shell and run wp db reset

Environment Info

Describe your environment.

  • What Operating System are you using?
    Mac OS 10.15.7
  • What versions of site software (Nginx, Apache, PHP, MySQL) is used?
    nginx: 1.16.0
    php: 7.4.1
  • What version of Local is installed?
    6.1.2+5473

Supporting info

I’ve also tried placing the following in a wp-cli.yml in the /public directory for my site as I found suggested somewhere…

db reset: socket: /Users/reggieofarrell/Library/Application Support/Local/run/0aiZUbn5Q/mysql/mysqld.sock

…but that didn’t seem to change anything

Trying to add the --socket flat on the command line while running the command like so…

wp db reset --socket=" /Users/reggieofarrell/Library/Application Support/Local/run/0aiZUbn5Q/mysql/mysqld.sock"

results in…

Error: Parameter errors:
unknown --socket parameter

Please provide your Local Log. See this Community Forum post for instructions on how to do so:

Include any screenshots or video recordings of the issue to help others reproduce.


Nobody huh?

1 Like

Same issue. I am on MacOS Monterey.

2 Likes

Same issue here. I looked through all old threads. Some claim you can define “–socket” option but that did not work for me.

Just like you said, I can run import/export… why doesn’t reset work?! Somebody help.

Possible cause and fix

I just came accross this issue. I was having the same error.
Verify that IPv6 is enabled and working on your connection

IPv6 may be required by your MySQL server and it may be failing at startup.
That was my case. I checked ~/.config/Local/local-lightning-verbose.log and saw the following error:

{"class":"Process","level":"warn","message":"2023-11-28T16:22:33.865910Z 0 [ERROR] [MY-010250] [Server] Failed to create a socket for IPv6 '::1': errno
: 97.","process":"mysql","thread":"main","timestamp":"2023-11-28T16:22:33.871Z"}
{"class":"Process","level":"warn","message":"2023-11-28T16:22:33.865927Z 0 [ERROR] [MY-010255] [Server] Can't create IP socket: Address family not supp
orted by protocol","process":"mysql","thread":"main","timestamp":"2023-11-28T16:22:33.872Z"}

I had IPv6 disabled at startup. Changed that setting and rebooted and I then could start sites without issues.

1 Like