diff --git a/examples/databases/mariadb/devbox.json b/examples/databases/mariadb/devbox.json index e4f9c8d2771..a0d92a093cb 100644 --- a/examples/databases/mariadb/devbox.json +++ b/examples/databases/mariadb/devbox.json @@ -21,6 +21,5 @@ "commit": "f80ac848e3d6f0c12c52758c0f25c10c97ca3b62" }, "env": { - "MYSQL_UNIX_PORT": "/tmp/devbox/mariadb/run/mysql.sock" } -} \ No newline at end of file +} diff --git a/examples/databases/mysql/devbox.d/mysql/my.cnf b/examples/databases/mysql/devbox.d/mysql/my.cnf new file mode 100644 index 00000000000..fbe15dd80be --- /dev/null +++ b/examples/databases/mysql/devbox.d/mysql/my.cnf @@ -0,0 +1,6 @@ +# MySQL configuration file + +[mariadbd] +# Change this port if 3306 is already used +#port = 3306 +log_error=mysql.log diff --git a/examples/databases/mysql/devbox.d/mysql80/my.cnf b/examples/databases/mysql/devbox.d/mysql80/my.cnf new file mode 100644 index 00000000000..a749c470084 --- /dev/null +++ b/examples/databases/mysql/devbox.d/mysql80/my.cnf @@ -0,0 +1,6 @@ +# MySQL configuration file + +# [mysqld] +# skip-log-bin +# Change this port if 3306 is already used +#port = 3306 diff --git a/examples/databases/mysql/devbox.d/mysql84/my.cnf b/examples/databases/mysql/devbox.d/mysql84/my.cnf new file mode 100644 index 00000000000..a749c470084 --- /dev/null +++ b/examples/databases/mysql/devbox.d/mysql84/my.cnf @@ -0,0 +1,6 @@ +# MySQL configuration file + +# [mysqld] +# skip-log-bin +# Change this port if 3306 is already used +#port = 3306 diff --git a/examples/databases/mysql/devbox.json b/examples/databases/mysql/devbox.json index 1465d180b6e..b308faf16f1 100644 --- a/examples/databases/mysql/devbox.json +++ b/examples/databases/mysql/devbox.json @@ -1,23 +1,18 @@ { - "packages": [ - "mysql80@latest" - ], + "packages": ["mysql84@latest"], "shell": { "init_hook": [], "scripts": { "connect_db": [ - "mysql -u devbox_user -p -D devbox_lamp" + "mysql -u devbox_user -p -D devbox_lamp", ], "test_db_setup": [ "mkdir -p /tmp/devbox/mariadb/run", "devbox services up -b", "sleep 5", "mysql -u root --password='' < setup_db.sql", - "devbox services stop" - ] - } + "devbox services stop", + ], + }, }, - "env": { - "MYSQL_UNIX_PORT": "/tmp/devbox/mariadb/run/mysql.sock" - } -} \ No newline at end of file +} diff --git a/examples/databases/mysql/devbox.lock b/examples/databases/mysql/devbox.lock index 48f1bffa039..8896605aaa5 100644 --- a/examples/databases/mysql/devbox.lock +++ b/examples/databases/mysql/devbox.lock @@ -1,68 +1,72 @@ { "lockfile_version": "1", "packages": { - "mysql80@latest": { - "last_modified": "2024-02-10T18:15:24Z", - "plugin_version": "0.0.3", - "resolved": "github:NixOS/nixpkgs/10b813040df67c4039086db0f6eaf65c536886c6#mysql80", + "github:NixOS/nixpkgs/nixpkgs-unstable": { + "last_modified": "2025-08-04T20:54:38Z", + "resolved": "github:NixOS/nixpkgs/cab778239e705082fe97bb4990e0d24c50924c04?lastModified=1754340878&narHash=sha256-lgmUyVQL9tSnvvIvBp7x1euhkkCho7n3TMzgjdvgPoU%3D" + }, + "mysql84@latest": { + "last_modified": "2025-08-08T11:17:04Z", + "plugin_version": "0.0.4", + "resolved": "github:NixOS/nixpkgs/b069b7c1e2fe1a3a24221428558bf44128d3d5c8#mysql84", "source": "devbox-search", - "version": "8.0.36", + "version": "8.4.6", "systems": { "aarch64-darwin": { "outputs": [ { "name": "out", - "path": "/nix/store/50hwl7vdz5lqdx3agn9f6q2dibcf8yms-mysql-8.0.36", + "path": "/nix/store/fab2yjsp2nb2vxkf1q9lizbxpvz72g7z-mysql-8.4.6", "default": true }, { "name": "static", - "path": "/nix/store/lhg44jksdla9j4m3g6wmlrrb55j5l3y8-mysql-8.0.36-static" + "path": "/nix/store/gi2cfbf7ma36yys3rphz59apwv798y6w-mysql-8.4.6-static" } ], - "store_path": "/nix/store/50hwl7vdz5lqdx3agn9f6q2dibcf8yms-mysql-8.0.36" + "store_path": "/nix/store/fab2yjsp2nb2vxkf1q9lizbxpvz72g7z-mysql-8.4.6" }, "aarch64-linux": { "outputs": [ { "name": "out", - "path": "/nix/store/g5kp969zy1mk2g5hdzzg69vw4g4m9sy0-mysql-8.0.36", + "path": "/nix/store/9fnq2ijz65q5q0bvd50279inbhmx9k31-mysql-8.4.6", "default": true }, { "name": "static", - "path": "/nix/store/29zyqbla4d9ax6hyv4myxdiy2xb109g5-mysql-8.0.36-static" + "path": "/nix/store/4nj305bgk0npv8p683s6fnrkr0f7kfy6-mysql-8.4.6-static" } ], - "store_path": "/nix/store/g5kp969zy1mk2g5hdzzg69vw4g4m9sy0-mysql-8.0.36" + "store_path": "/nix/store/9fnq2ijz65q5q0bvd50279inbhmx9k31-mysql-8.4.6" }, "x86_64-darwin": { "outputs": [ { "name": "out", - "path": "/nix/store/h48pc9is6jw3nxzai5gd025y51c361lj-mysql-8.0.36", + "path": "/nix/store/m53dgvffnpr5xn0phf220qipqpzw04qx-mysql-8.4.6", "default": true }, { "name": "static", - "path": "/nix/store/s030q0ibyw32sa755qygi8m0zyf8qn8s-mysql-8.0.36-static" + "path": "/nix/store/8ki39xjalywa5f83a716bhmva8lh39k9-mysql-8.4.6-static" } ], - "store_path": "/nix/store/h48pc9is6jw3nxzai5gd025y51c361lj-mysql-8.0.36" + "store_path": "/nix/store/m53dgvffnpr5xn0phf220qipqpzw04qx-mysql-8.4.6" }, "x86_64-linux": { "outputs": [ { "name": "out", - "path": "/nix/store/vwcld5bqs1dg7h2ffcgz8am4vdrxw176-mysql-8.0.36", + "path": "/nix/store/5jkdn4wrr079d5xm14mz0c44fsgqwq4z-mysql-8.4.6", "default": true }, { "name": "static", - "path": "/nix/store/x8rlbq0z80nqldwvxs4w2rblp3yjwn0z-mysql-8.0.36-static" + "path": "/nix/store/c8r41hrvjiim2vyjcqq81nr7z3g8h11x-mysql-8.4.6-static" } ], - "store_path": "/nix/store/vwcld5bqs1dg7h2ffcgz8am4vdrxw176-mysql-8.0.36" + "store_path": "/nix/store/5jkdn4wrr079d5xm14mz0c44fsgqwq4z-mysql-8.4.6" } } } diff --git a/examples/databases/mysql/my.cnf b/examples/databases/mysql/my.cnf new file mode 100644 index 00000000000..11894c92f51 --- /dev/null +++ b/examples/databases/mysql/my.cnf @@ -0,0 +1,22 @@ +[mysqld] +# Use a different port to avoid conflicts +port = 3307 + +# Basic settings +datadir = .devbox/virtenv/mysql80/data +pid-file = .devbox/virtenv/mysql80/run/mysql.pid +log-error = .devbox/virtenv/mysql80/run/mysql-error.log +socket = .devbox/virtenv/mysql80/run/mysql.sock +lc_messages_dir = .devbox/virtenv/mysql80/share/mysql/ +lc_messages = en_US + +# Disable X Plugin which also causes conflicts +mysqlx = 0 + +# Performance settings +max_connections = 100 +key_buffer_size = 16M +max_allowed_packet = 16M + +[client] +socket = .devbox/virtenv/mysql80/run/mysql.sock diff --git a/plugins/builtins.go b/plugins/builtins.go index 346b19c236d..06a1005ef80 100644 --- a/plugins/builtins.go +++ b/plugins/builtins.go @@ -30,7 +30,7 @@ var builtInMap = map[*regexp.Regexp]string{ regexp.MustCompile(`^elixir_?([0-9_]*[0-9]+)?$`): "elixir", regexp.MustCompile(`^(ghc|haskell\.compiler\.(.*))$`): "haskell", regexp.MustCompile(`(^mariadb(-embedded)?_?[0-9]*$|^mysql$)`): "mariadb", - regexp.MustCompile(`^mysql(80|57|50)$`): "mysql", + regexp.MustCompile(`^mysql(8[0-9]|57|50)$`): "mysql", regexp.MustCompile(`^nodejs(-slim)?_?[0-9]*$`): "nodejs", regexp.MustCompile(`^php[0-9]*$`): "php", regexp.MustCompile(`^python3[0-9]*Packages.pip$`): "pip", diff --git a/plugins/mariadb/process-compose.yaml b/plugins/mariadb/process-compose.yaml index d8d78556340..674ee04a28b 100644 --- a/plugins/mariadb/process-compose.yaml +++ b/plugins/mariadb/process-compose.yaml @@ -2,10 +2,10 @@ version: "0.5" processes: mariadb: - command: "echo 'Starting mysqld... check mariadb_logs for details'; mysqld --log-error=$MYSQL_HOME/mysql.log" + command: "echo 'Starting mysqld... check mariadb_logs for details'; mariadbd --log-error=$MYSQL_HOME/mysql.log" is_daemon: false shutdown: - command: "mysqladmin -u root shutdown" + command: "mariadb-admin -u root shutdown" availability: restart: "always" mariadb_logs: diff --git a/plugins/mysql/flake.nix b/plugins/mysql/flake.nix index 67cf8e523dd..74787d4497e 100644 --- a/plugins/mysql/flake.nix +++ b/plugins/mysql/flake.nix @@ -15,10 +15,10 @@ postBuild = '' wrapProgram $out/bin/mysqld \ - --add-flags '--basedir=$out --datadir=''$MYSQL_DATADIR --pid-file=''$MYSQL_PID_FILE --socket=''$MYSQL_UNIX_PORT'; + --add-flags '--basedir=''$MYSQL_BASEDIR --datadir=''$MYSQL_DATADIR --pid-file=''$MYSQL_PID_FILE --socket=''$MYSQL_UNIX_PORT'; wrapProgram $out/bin/mysqld_safe \ - --add-flags '--basedir=$out --datadir=''$MYSQL_DATADIR --pid-file=''$MYSQL_PID_FILE --socket=''$MYSQL_UNIX_PORT'; + --add-flags '--basedir=''$MYSQL_BASEDIR --datadir=''$MYSQL_DATADIR --pid-file=''$MYSQL_PID_FILE --socket=''$MYSQL_UNIX_PORT'; ''; }; in{ diff --git a/plugins/mysql/setup_db.sh b/plugins/mysql/setup_db.sh index 5f883d56759..6f718378329 100644 --- a/plugins/mysql/setup_db.sh +++ b/plugins/mysql/setup_db.sh @@ -2,10 +2,16 @@ if [ ! -d "$MYSQL_DATADIR" ]; then # Install the Database - mkdir $MYSQL_DATADIR - mysqld --initialize-insecure + mkdir -p $MYSQL_DATADIR + mysqld --initialize-insecure --basedir=$MYSQL_BASEDIR +fi + +# Create run directory for socket files if it doesn't exist +MYSQL_RUN_DIR="$(dirname $MYSQL_UNIX_PORT)" +if [ ! -d "$MYSQL_RUN_DIR" ]; then + mkdir -p "$MYSQL_RUN_DIR" fi if [ -e "$MYSQL_CONF" ]; then ln -fs "$MYSQL_CONF" "$MYSQL_HOME/my.cnf" -fi \ No newline at end of file +fi