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

mariadb (but not mysql) does not respect the MYSQL_UNIX_PORT env variable #2522

Open
jefft opened this issue Feb 17, 2025 · 0 comments
Open
Labels
bug Something isn't working triage Issue needs triage

Comments

@jefft
Copy link
Contributor

jefft commented Feb 17, 2025

What happened?

To replicate:

cd /tmp
devbox create mariadbtest --template mariadb
cd mariadbtest
devbox run bash -c 'echo $MYSQL_UNIX_PORT'  # Prints /tmp/mariadbtest/.devbox/virtenv/mariadb/run/mysql.sock
# Note: do not start mariadb. This means we expect the connect attempt to fail
devbox run mariadb

The output ends with:

ERROR 2002 (HY000): Can't connect to local server through socket '/run/mysqld/mysqld.sock' (2)

This shows that the socket path, MYSQL_UNIX_PORT, is not being read.

To show that this is buggy, run the exact same steps with mysql instead of mariadb:

cd /tmp
devbox create mysqltest --template mysql
cd mysqltest
devbox run bash -c 'echo $MYSQL_UNIX_PORT'  # Prints /tmp/mysqltest/.devbox/virtenv/mysql80/run/mysql.sock
# Note: do not start mysql. This means we expect the connect attempt to fail
devbox run mysql

This prints

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysqltest/.devbox/virtenv/mysql80/run/mysql.sock' (2)

which is correct - the MYSQL_UNIX_PORT socket is being used.


Perhaps this is an upstream mariadb bug. A fix/workaround would be for Devbox's mariadb flake.nix to generate mysql and mariadb wrappers that set --socket=$MYSQL_UNIX_PORT.

Steps to reproduce

No response

Command

No response

devbox.json

Devbox version

0.14.0

Nix version

nix (Nix) 2.18.5

What system does this bug occur on?

Linux (x86-64)

Debug logs

No response

@jefft jefft added bug Something isn't working triage Issue needs triage labels Feb 17, 2025
jefft added a commit to jefft/devbox that referenced this issue Feb 18, 2025
devbox.json. Also for mariadb, specify --socket to work around jetify-com#2522.
jefft added a commit to jefft/devbox that referenced this issue Feb 18, 2025
…NIX_PORT, since strangely, the native binaries do not (jetify-com#2522). Also specify the root user/password.
Lagoja added a commit that referenced this issue Mar 11, 2025
…ort path (#2523)

..rather than plugin's project-relative path, to avoid triggering 'The
socket file path is too long (> 107)' error on start. Also specify the
(blank) password in 'test_db_setup'. Fixes #2521

## How was it tested?

Per the description in #2521, after this change `mysqld` should come up
in a >107 length path, e.g.:
```
cd ~/src/github.com/jetify-com/devbox/examples/databases/mysql
devbox services up -b
tail -1 .devbox/compose.log  # This shows the socket path, which should now be /tmp/devbox/mariadb/run/mysql.sock
devbox run mysql -u root -p   # Blank password - connects
```

Note: I have patched mysql and mariadb because they are essentially the
same. However whereas `mysql` respects the `MYSQL_UNIX_PORT` env
variable, `mysql` from the mariadb package does not (logged as #2522),
so the last step of this code fails:
```
cd ~/src/github.com/jetify-com/devbox/examples/databases/mariadb
devbox services up -b
tail -1 .devbox/compose.log  # This shows the socket path, which should now be /tmp/devbox/mariadb/run/mysql.sock
devbox run mysql -u root -p   # ERROR 2002 (HY000): Can't connect to local server through socket '/run/mysqld/mysqld.sock' (2)
```
Aside from testing, this mariadb bug is irrelevant to this patch. I just
thought I'd mention it.

---------

Signed-off-by: dependabot[bot] <[email protected]>
Signed-off-by: John Lago <[email protected]>
Co-authored-by: Artem Klevtsov <[email protected]>
Co-authored-by: Greg Curtis <[email protected]>
Co-authored-by: Daniel Loreto <[email protected]>
Co-authored-by: Mike Landau <[email protected]>
Co-authored-by: John Lago <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Will Brennan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage Issue needs triage
Development

No branches or pull requests

1 participant