Issue Summary
Trying to open Adminer I get a ERR_UNSAFE_PORT error. None of my sites are able to open adminer or access any databases.
Using Site Shell and for instance a command like wp db reset
gives me this error: 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
Which version of Local is being used?
6.1.8+5621
What Operating System (OS) and OS version is being used?
macOS Monterey
Attach the Local Log. See this Community Forum post for instructions on how to do so:
local-lightning.log (253.3 KB)
ERR_UNSAFE_PORT
is definitely an odd error! What port is Local opening?
I know that WPCLI needs an update in order for some of these things to work. I think that it’s been fixed, since this bug report I opened has been closed, but I don’t think the code has been merged into a stable release of WPCLI:
opened 10:56PM - 12 Feb 21 UTC
closed 01:56PM - 26 Jul 21 UTC
## Bug Report
- [x] Yes, I reviewed the [contribution guidelines](https://mak… e.wordpress.org/cli/handbook/contributing/).
- [x] Yes, more specifically, I reviewed the guidelines on [how to write clear bug reports](https://make.wordpress.org/cli/handbook/bug-reports/).
**Describe the current, buggy behavior**
When using wpcli in an environment that needs the `--defaults` flag (like [Local](https://localwp.com) ), the `clean`, `create`, `drop`, and `reset` subcommands are not working.
When running these commands, I get this error within the terminal:
```
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
```
The problem is that the above socket (`/tmp/mysql.sock`) isn't the correct one for the environment. Here are some details from my site's terminal session:
```
★ app/public % which mysql
/Applications/Local.app/Contents/Resources/extraResources/lightning-services/mysql-8.0.16+5/bin/darwin/bin/mysql
★ app/public % ps aux | grep mysql
benjamin 73741 0.2 0.6 4487024 94948 ?? S 2:01PM 0:08.94 /Applications/Local.app/Contents/Resources/extraResources/lightning-services/mysql-8.0.16+5/bin/darwin/bin/mysqld --defaults-file=/Users/benjamin/Library/Application Support/Local/run/Q1Jz6TdXS/conf/mysql/my.cnf
benjamin 75797 0.0 0.0 4258892 216 s002 U+ 2:28PM 0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn --exclude-dir=.idea --exclude-dir=.tox mysq
★ app/public % cat ~//Library/Application\ Support/Local/run/Q1Jz6TdXS/conf/mysql/my.cnf
[mysqld]
skip-name-resolve
mysqlx = 0
datadir = /Users/benjamin/Library/Application Support/Local/run/Q1Jz6TdXS/mysql/data
port = 10024
bind-address = 127.0.0.1,::1
socket = /Users/benjamin/Library/Application Support/Local/run/Q1Jz6TdXS/mysql/mysqld.sock
# Older PHP/client compatibility
character-set-server = utf8mb3
default_authentication_plugin = mysql_native_password
# Fine Tuning
performance_schema = off
max_allowed_packet = 16M
thread_stack = 192K
thread_cache_size = 8
# InnoDB
innodb_buffer_pool_size = 32M
innodb_log_file_size = 96M
[client]
socket = /Users/benjamin/Library/Application Support/Local/run/Q1Jz6TdXS/mysql/mysqld.sock
user = root
password = root
```
**Describe how other contributors can replicate this bug**
You might be able to replicate by having a custom MySQL config and using the `--defaults` flag, but the easiest way I know is to use Local:
- Create a new site within [Local](https://localwp.com)
- Right-click on the site in Local and select "Open Site Shell." This will open a terminal and configure the environment variables
- Run any of the subcommands that are having issue: `clean`, `create`, `drop`, or `reset`
- You should see an error related to being unable to connect to MySQL:
```
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
```
**Describe what you would expect as the correct outcome**
I would expect that all `db` subcommands should work by being able to use the same socket connection.
**Let us know what environment you are running this on**
```
★ app/public % wp cli info
OS: Darwin 19.6.0 Darwin Kernel Version 19.6.0: Tue Nov 10 00:10:30 PST 2020; root:xnu-6153.141.10~1/RELEASE_X86_64 x86_64
Shell: /bin/zsh
PHP binary: /Applications/Local.app/Contents/Resources/extraResources/lightning-services/php-7.3.5+10/bin/darwin/bin/php
PHP version: 7.3.5
php.ini used: /Users/benjamin/Library/Application Support/Local/run/Q1Jz6TdXS/conf/php/php.ini
WP-CLI root dir: phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir: phar://wp-cli.phar/vendor
WP_CLI phar path: /Users/benjamin/Local Sites/site-reset/app/public
WP-CLI packages dir: /Users/benjamin/.wp-cli/packages/
WP-CLI global config: /Applications/Local.app/Contents/Resources/extraResources/bin/wp-cli/config.yaml
WP-CLI project config:
WP-CLI version: 2.5.0-alpha
```
**Provide a possible solution**
Taking a look at those functions that produce errors, it seems like maybe they need to be refactored to not use `$this->run_query(...`
I'm new to the wpcli project, so I might see if I can get something working, but if anyone has pointers, I'd love to learn more!
**Provide additional context/Screenshots**
It looks like this is related to the with the work done in #157 however, a few subcommands weren't covered.
1 Like
Ahh crap! Yep, that’s a bug that we’re just finishing up this sprint and should be released in the next version of Local.
Basically, there’s a security risk of using port 10080
and because of that, Chrome blocks that port:
As a workaround for today before the release of the new version of Local, I think you should be able to export the site by right-clicking on it in Local and then import the zip to create a new site that uses a new port.
Hi Ben!
When will this new version be out?
I have 16 sites as of now, and all of them opens on that port. Do I need to clone each one?
Also, I find it weird that this will fix them as all of them have this issue…?
We don’t have a specific ETA for when the release will come, but soon!
I don’t think you’ll need to clone each one, but you should try exporting and importing the first one to see how it goes!
Is there a way for me to avoid exporting / importing? Could I instead change some configurations, etc.?
system
Closed
April 10, 2022, 7:39pm
9
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.