Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using DBngin - error: mysql: No such file or directory #78

Closed
nathangross opened this issue Aug 26, 2021 · 3 comments
Closed

Using DBngin - error: mysql: No such file or directory #78

nathangross opened this issue Aug 26, 2021 · 3 comments

Comments

@nathangross
Copy link

Laravel Valet docs now seemingly suggest using DBngin for local database management. That's how I'm currently set up. If I run wp valet new bedrock --project=bedrock I get the following Error: Failed to get current SQL modes. Reason: env: mysql: No such file or directory

I'm curious if it is possible to get this to work properly with DBngin.

Thanks in advance!

@aaemnnosttv
Copy link
Owner

Hey there – I don't see why it wouldn't work, although I've never seen that error before. What version of MySQL are you trying to use? The command doesn't really do anything special mysql-wise so as long as your db host and credentials as set correctly it should work (that's not what the error is complaining about though).

Looks like the same error here: wp-cli/db-command#176 (comment) maybe that helps?

I would try running the same command with --debug and see where the error is happening internally with wp-cli (probably wp core install) then we can see if it's a problem with the valet command or wp-cli itself.

@nathangross
Copy link
Author

nathangross commented Aug 27, 2021

Hey, thanks for the reply!

Since posting, I went ahead and installed mysql via home brew as well as brew services start mysql. Running the command wp valet new bedrock --project=bedrock works great—as expected.

However, If stop Homebrew mysql, start up DBngin's mysql and run that command I get Error: Failed to get current SQL modes. Reason: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2). Which absolutely makes sense because it is still looking in the same place for mysql (where homebrew installs it).

Is there a way to configure it to look for a specific install of mysql?

fwiw here is the output of the --debug install:

https://gist.github.com/nathangross/a891865de6fbac8f4d0ae4417541ac97

@aaemnnosttv
Copy link
Owner

aaemnnosttv commented Aug 28, 2021

Hey there, I see what the problem is now. It looks like DBngin does not use the same location for the Unix socket /tmp/mysql.sock. Instead, for me it seems to use the configured port # as part of the socket name: e.g. /tmp/mysql_3306.sock (which makes sense because DBngin is designed to run multiple DB instances simultaneously). This fails because mysql is trying to use /tmp/mysql.sock for whatever reason. When using the Homebrew-installed mysql/mariadb, this socket is in this location so it works. The Laravel docs mention connecting via 127.0.0.1 which you should find does work (assuming the instance is set up to use the default port of 3306).

WP CLI defaults to localhost as the DB host which is always interpreted as "use the unix socket" to connect rather than TCP. We have an issue on the repo here to allow customizing this when creating a new site in #73 but if you change your DB_HOST in wp-config.php to 127.0.0.1, it should work with DBngine just fine, although until that issue is done, you wouldn't be able to create a new site with the Valet command using DBngine without additional changes to your wp-cli config. You can create/update your wp-cli config file to set the default dbhost to 127.0.0.1 although this would have to be done for the core command (e.g. config create – see the readme for an example of how this works although this example is for the valet new command but the same approach works for any other)

I hope that makes sense. See this excellent write up about mysql connections for more information. This is ultimately not really an issue with the command itself though (other than what's already covered by #73) so I'm going to close this one out. Hopefully this information helps anyone else running into the same problem though. Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants