diff --git a/docs/app/docs/devbox_examples/databases/mysql.md b/docs/app/docs/devbox_examples/databases/mysql.md index 4d73d5594ac..a4fd9ccab41 100644 --- a/docs/app/docs/devbox_examples/databases/mysql.md +++ b/docs/app/docs/devbox_examples/databases/mysql.md @@ -46,11 +46,16 @@ MYSQL_BASEDIR=.devbox/nix/profile/default MYSQL_HOME=./.devbox/virtenv/mysql/run MYSQL_DATADIR=./.devbox/virtenv/mysql/data MYSQL_UNIX_PORT=./.devbox/virtenv/mysql/run/mysql.sock -MYSQL_PID_FILE=./.devbox/mysql/run/mysql.pid +MYSQL_PID_FILE=./.devbox/virtenv/mysql/run/mysql.pid +MYSQL_CONF=./devbox.d/mysql/my.cnf ``` ### Files +The following helper file will be created in your project directory: + +* \{PROJECT_DIR\}/devbox.d/mysql/my.cnf + The plugin will also create the following helper files in your project's `.devbox/virtenv` folder: * mysql/flake.nix diff --git a/plugins/builtins.go b/plugins/builtins.go index 15a7204d05e..ac4c8180eb6 100644 --- a/plugins/builtins.go +++ b/plugins/builtins.go @@ -28,8 +28,8 @@ var builtInMap = map[*regexp.Regexp]string{ regexp.MustCompile(`^(apache|apacheHttpd)$`): "apacheHttpd", regexp.MustCompile(`^(gradle|gradle_[0-9])$`): "gradle", regexp.MustCompile(`^(ghc|haskell\.compiler\.(.*))$`): "haskell", - regexp.MustCompile(`^mariadb(-embedded)?_?[0-9]*$`): "mariadb", - regexp.MustCompile(`^mysql?[0-9]*$`): "mysql", + regexp.MustCompile(`(^mariadb(-embedded)?_?[0-9]*$|^mysql$)`): "mariadb", + regexp.MustCompile(`^mysql(80|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/builtins_test.go b/plugins/builtins_test.go index e3d900f0fa6..3c7597ecfe0 100644 --- a/plugins/builtins_test.go +++ b/plugins/builtins_test.go @@ -20,7 +20,7 @@ func TestBuiltInMap(t *testing.T) { "mariadb": "mariadb", "mariadb_1011": "mariadb", "mariadb-embedded": "mariadb", - "mysql": "mysql", + "mysql": "mariadb", "mysql80": "mysql", "python3Packages.pip": "pip", "python": "python", diff --git a/plugins/mariadb.json b/plugins/mariadb.json index 7c1becee5c1..9bb5d776fd3 100644 --- a/plugins/mariadb.json +++ b/plugins/mariadb.json @@ -13,7 +13,8 @@ "{{ .Virtenv }}/run": "", "{{ .Virtenv }}/flake/flake.nix": "mariadb/flake.nix", "{{ .Virtenv }}/setup_db.sh": "mariadb/setup_db.sh", - "{{ .Virtenv }}/process-compose.yaml": "mariadb/process-compose.yaml" + "{{ .Virtenv }}/process-compose.yaml": "mariadb/process-compose.yaml", + "{{ .DevboxDir }}/my.cnf": "mariadb/my.cnf" }, "packages": { "path:{{ .Virtenv }}/flake": {}, diff --git a/plugins/mariadb/my.cnf b/plugins/mariadb/my.cnf new file mode 100644 index 00000000000..0f6f43f0880 --- /dev/null +++ b/plugins/mariadb/my.cnf @@ -0,0 +1,4 @@ +# MySQL configuration file + +[mariadb] +log_error=mysql.log diff --git a/plugins/mariadb/setup_db.sh b/plugins/mariadb/setup_db.sh index fb5a271b908..3116d2744cb 100644 --- a/plugins/mariadb/setup_db.sh +++ b/plugins/mariadb/setup_db.sh @@ -6,3 +6,7 @@ if [ ! -d "$MYSQL_DATADIR" ]; then --datadir=$MYSQL_DATADIR --basedir=$MYSQL_BASEDIR \ --pid-file=$MYSQL_PID_FILE fi + +if [ -e "$MYSQL_CONF" ]; then + ln -fs "$MYSQL_CONF" "$MYSQL_HOME/my.cnf" +fi \ No newline at end of file diff --git a/plugins/mysql.json b/plugins/mysql.json index ea0a0b5926d..d982fc5bb8f 100644 --- a/plugins/mysql.json +++ b/plugins/mysql.json @@ -1,31 +1,31 @@ { - "name": "mysql", - "version": "0.0.3", - "description": "* This plugin wraps mysqld and mysql_install_db to work in your local project\n* This plugin will create a new database for your project in MYSQL_DATADIR if one doesn't exist on shell init. This DB will be started in `insecure` mode, so be sure to add a root password after creation if needed.\n* Use mysqld to manually start the server, and `mysqladmin -u root shutdown` to manually stop it", - "env": { - "MYSQL_BASEDIR": "{{ .DevboxProfileDefault }}", - "MYSQL_HOME": "{{ .Virtenv }}/run", - "MYSQL_DATADIR": "{{ .Virtenv }}/data", - "MYSQL_UNIX_PORT": "{{ .Virtenv }}/run/mysql.sock", - "MYSQL_PID_FILE": "{{ .Virtenv }}/run/mysql.pid" - }, - "create_files": { - "{{ .Virtenv }}/run": "", - "{{ .Virtenv }}/flake/flake.nix": "mysql/flake.nix", - "{{ .Virtenv }}/setup_db.sh": "mysql/setup_db.sh", - "{{ .Virtenv }}/process-compose.yaml": "mysql/process-compose.yaml" - }, - "packages": { - "path:{{ .Virtenv }}/flake": {}, - "glibcLocales": { - "version": "latest", - "platforms": ["x86_64-linux", "aarch64-linux"] - } - }, - "__remove_trigger_package": true, - "shell": { - "init_hook": [ - "bash {{ .Virtenv }}/setup_db.sh" - ] + "name": "mysql", + "version": "0.0.4", + "description": "* This plugin wraps mysqld and mysql_install_db to work in your local project\n* This plugin will create a new database for your project in MYSQL_DATADIR if one doesn't exist on shell init. This DB will be started in `insecure` mode, so be sure to add a root password after creation if needed.\n* Use mysqld to manually start the server, and `mysqladmin -u root shutdown` to manually stop it", + "env": { + "MYSQL_BASEDIR": "{{ .DevboxProfileDefault }}", + "MYSQL_HOME": "{{ .Virtenv }}/run", + "MYSQL_DATADIR": "{{ .Virtenv }}/data", + "MYSQL_UNIX_PORT": "{{ .Virtenv }}/run/mysql.sock", + "MYSQL_PID_FILE": "{{ .Virtenv }}/run/mysql.pid", + "MYSQL_CONF": "{{ .DevboxDir }}/my.cnf" + }, + "create_files": { + "{{ .Virtenv }}/run": "", + "{{ .Virtenv }}/flake/flake.nix": "mysql/flake.nix", + "{{ .Virtenv }}/setup_db.sh": "mysql/setup_db.sh", + "{{ .Virtenv }}/process-compose.yaml": "mysql/process-compose.yaml", + "{{ .DevboxDir }}/my.cnf": "mysql/my.cnf" + }, + "packages": { + "path:{{ .Virtenv }}/flake": {}, + "glibcLocales": { + "version": "latest", + "platforms": ["x86_64-linux", "aarch64-linux"] } + }, + "__remove_trigger_package": true, + "shell": { + "init_hook": ["bash {{ .Virtenv }}/setup_db.sh"] } +} diff --git a/plugins/mysql/my.cnf b/plugins/mysql/my.cnf new file mode 100644 index 00000000000..734764813cd --- /dev/null +++ b/plugins/mysql/my.cnf @@ -0,0 +1,4 @@ +# MySQL configuration file + +# [mysqld] +# skip-log-bin diff --git a/plugins/mysql/setup_db.sh b/plugins/mysql/setup_db.sh index fc1187b3bd3..5f883d56759 100644 --- a/plugins/mysql/setup_db.sh +++ b/plugins/mysql/setup_db.sh @@ -1,7 +1,11 @@ #! bash if [ ! -d "$MYSQL_DATADIR" ]; then -# Install the Database - mkdir $MYSQL_DATADIR - mysqld --initialize-insecure + # Install the Database + mkdir $MYSQL_DATADIR + mysqld --initialize-insecure fi + +if [ -e "$MYSQL_CONF" ]; then + ln -fs "$MYSQL_CONF" "$MYSQL_HOME/my.cnf" +fi \ No newline at end of file