Open Site Shell does not use local mysql sock

What issue or error are you experiencing?

I cannot use the site shell in the local container. It seems to be referencing outside the container ~/Local Sites/test/app/public which means the mysql sock used is from my machine, and not in the container.


What steps can be taken to replicate the issue? Feel free to include screenshots, videos, etc

I get a range of issues, however, I am unable to connect to wp db reset --yes because the mysql sock is using /tmp/mysql.sock rather than the local one.

❯ wp db reset --yes
Failed loading /Users/michael/Library/Application Support/Local/lightning-services/php-8.1.23+0/bin/darwin-arm64/lib/php/extensions/no-debug-non-zts-20210902/opcache.so:  dlopen(/Users/michael/Library/Application Support/Local/lightning-services/php-8.1.23+0/bin/darwin-arm64/lib/php/extensions/no-debug-non-zts-20210902/opcache.so, 0x0009): symbol not found in flat namespace '_zend_alloc_ce_cache'
Failed loading /Users/michael/Library/Application Support/Local/lightning-services/php-8.1.23+0/bin/darwin-arm64/lib/php/extensions/no-debug-non-zts-20210902/xdebug.so:  dlopen(/Users/michael/Library/Application Support/Local/lightning-services/php-8.1.23+0/bin/darwin-arm64/lib/php/extensions/no-debug-non-zts-20210902/xdebug.so, 0x0009): symbol not found in flat namespace '_zend_is_graceful_exit'

Warning: PHP Startup: imagick: Unable to initialize module
Module compiled with module API=20210902
PHP    compiled with module API=20200930
These options need to match
 in Unknown on line 0
Error: Failed to get current SQL modes. Reason: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

System Details

  • Local Version: 8.0.0

  • Operating System (OS) and OS version:
    Mac OS Sonoma


Local Logs

Attach your Local Logs here (Help Doc - Retrieving Local’s Log)

local-logs.zip (98.5 KB)


Security Reminder
Local does a pretty good job of scrubbing private info from the logs and the errors it produces, however there’s always the possibility that something private can come through. Because these are public forums, always review the screenshots you are sharing to make sure there isn’t private info like passwords being displayed.

It seems to be working properly after adding the socket like this:

  1. Copy the socket path
  2. Add the socket path into the DB_HOST found in wp-config.php file
  3. Make sure to add localhost: before the socket path


Thanks for reporting this issue @mic ! We were able to replicate so I’ve moved this to the “bug” category.

Taking a closer look at the issue, it looks like we need to update the wp-cli config that Local uses so that wpcli is pointing to the correct DB socket.

This was also affecting the clean, create, and drop commands.

I have a fix in the works and should be released in an upcoming release of Local.

If you don’t want to wait for the fix, you should be able to run any of these commands by adding the --defaults flag to the command.

So for the command you mentioned above, that would look like:

wp db reset --yes --defaults

Again, you only need to add that until we get our fix merged and released. Thanks again for reporting this bug and let us know if you need anything else!

1 Like

I’ve been using TCP/IP for quite some time and it seems to work with WP-CLI.

// ** Database settings ** //

/** The name of the database for WordPress */
define('DB_NAME', 'local');

/** Database username */
define('DB_USER', 'root');

/** Database password */
define('DB_PASSWORD', 'root');

/** Database hostname */
define('DB_HOST', 'localhost');
1 Like

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