Skip to content

Commit 3e236b4

Browse files
jefftartemklevtsovgcurtisloretomikeland73
authored
In the mysql/mariadb templates, set MYSQL_UNIX_PORT to a hardcoded short 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]>
1 parent 9eba0e3 commit 3e236b4

File tree

4 files changed

+14
-22
lines changed

4 files changed

+14
-22
lines changed

examples/databases/mariadb/README.md

+2-8
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## mariadb Notes
44

55
1. Start the mariadb server using `devbox services up`
6-
1. Create a database using `"mysql -u root < setup_db.sql"`
6+
1. Create a database using `"mysql --socket-path=$MYSQL_UNIX_PORT --password='' < setup_db.sql"`
77
1. You can now connect to the database from the command line by running `devbox run connect_db`
88

99
## Services
@@ -22,10 +22,4 @@ Use `devbox services start|stop [service]` to interact with services
2222

2323
To show this information, run `devbox info mariadb`
2424

25-
Note that the `.sock` filepath can only be maximum 100 characters long. You can point to a different path by setting the `MYSQL_UNIX_PORT` env variable in your `devbox.json` as follows:
26-
27-
```
28-
"env": {
29-
"MYSQL_UNIX_PORT": "/<some-other-path>/mysql.sock"
30-
}
31-
```
25+
Note that the `.sock` filepath can only be maximum 100 characters long. You can point to a different path by setting the `MYSQL_UNIX_PORT` env variable in your `devbox.json`.

examples/databases/mariadb/devbox.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,17 @@
1010
],
1111
"test_db_setup": [
1212
"mkdir -p /tmp/devbox/mariadb/run",
13-
"export MYSQL_UNIX_PORT=/tmp/devbox/mariadb/run/mysql.sock",
1413
"devbox services up -b",
1514
"sleep 5",
16-
"mysql -u root < setup_db.sql",
15+
"mysql -u root --password='' < setup_db.sql",
1716
"devbox services stop"
1817
]
1918
}
2019
},
2120
"nixpkgs": {
2221
"commit": "f80ac848e3d6f0c12c52758c0f25c10c97ca3b62"
23-
}
22+
},
23+
"env": {
24+
"MYSQL_UNIX_PORT": "/tmp/devbox/mariadb/run/mysql.sock"
25+
}
2426
}

examples/databases/mysql/README.md

+2-8
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## mysql Notes
44

55
1. Start the mysql server using `devbox services up`
6-
1. Create a database using `"mysql -u root < setup_db.sql"`
6+
1. Create a database using `"mysql -u root --password='' < setup_db.sql"`
77
1. You can now connect to the database from the command line by running `devbox run connect_db`
88

99
## Services
@@ -22,10 +22,4 @@ Use `devbox services start|stop [service]` to interact with services
2222

2323
To show this information, run `devbox info mysql`
2424

25-
Note that the `.sock` filepath can only be maximum 100 characters long. You can point to a different path by setting the `MYSQL_UNIX_PORT` env variable in your `devbox.json` as follows:
26-
27-
```json
28-
"env": {
29-
"MYSQL_UNIX_PORT": "/<some-other-path>/mysql.sock"
30-
}
31-
```
25+
Note that the `.sock` filepath can only be maximum 100 characters long. You can point to a different path by setting the `MYSQL_UNIX_PORT` env variable in your `devbox.json`.

examples/databases/mysql/devbox.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@
1010
],
1111
"test_db_setup": [
1212
"mkdir -p /tmp/devbox/mariadb/run",
13-
"export MYSQL_UNIX_PORT=/tmp/devbox/mariadb/run/mysql.sock",
1413
"devbox services up -b",
1514
"sleep 5",
16-
"mysql -u root < setup_db.sql",
15+
"mysql -u root --password='' < setup_db.sql",
1716
"devbox services stop"
1817
]
1918
}
20-
}
19+
},
20+
"env": {
21+
"MYSQL_UNIX_PORT": "/tmp/devbox/mariadb/run/mysql.sock"
22+
}
2123
}

0 commit comments

Comments
 (0)