diff --git a/stack/erp5/buildout.hash.cfg b/stack/erp5/buildout.hash.cfg
index 66b705f89bf21c50c064208783549d0d802c6331..0addcb26f4be2676c6e3d640900c3acd39f969a0 100644
--- a/stack/erp5/buildout.hash.cfg
+++ b/stack/erp5/buildout.hash.cfg
@@ -19,7 +19,7 @@ md5sum = 372e5247d0a1514f3406228407b10d77
 
 [template-mariadb]
 filename = instance-mariadb.cfg.in
-md5sum = 22270cd739fe00c45d0605dfb7edd2eb
+md5sum = 9ee9c331b2d4f81f85c3ef47af0e6d4a
 
 [template-kumofs]
 filename = instance-kumofs.cfg.in
diff --git a/stack/erp5/instance-mariadb.cfg.in b/stack/erp5/instance-mariadb.cfg.in
index c8f017d394a099a390a1e3ac25b232141b079969..a50cd4e0e77f4d617e23af0dfbf9d974bc62c245 100644
--- a/stack/erp5/instance-mariadb.cfg.in
+++ b/stack/erp5/instance-mariadb.cfg.in
@@ -155,14 +155,22 @@ mysql = ${binary-wrap-mysql:wrapper-path}
 init-script = ${init-script:rendered}
 mysql_tzinfo_to_sql = ${binary-wrap-mysql_tzinfo_to_sql:wrapper-path}
 
-[mysqld]
-recipe = slapos.cookbook:generic.mysql.wrap_mysqld
-output = ${directory:services}/mariadb
-binary = {{ parameter_dict['mariadb-location'] }}/bin/mysqld
-configuration-file = ${my-cnf:rendered}
-data-directory = ${my-cnf-parameters:data-directory}
-mysql-install-binary = {{ parameter_dict['mariadb-location'] }}/scripts/mysql_install_db
-mysql-base-directory = {{ parameter_dict['mariadb-location'] }}
+[{{ section('mysqld') }}]
+< = jinja2-template-executable
+# Note: all rendering is done when this file is rendered, not when the mysqld
+# section is installed - so I only use jinja2 as a fancy way to write an
+# executable file with partition-dependent but instance-parameters independent
+# content.
+template = inline:#!{{ parameter_dict['dash-location'] }}/bin/dash
+  '{{ parameter_dict['mariadb-location'] }}/scripts/mysql_install_db' \
+    --defaults-file='${my-cnf:rendered}' \
+    --skip-name-resolve \
+    --datadir='${my-cnf-parameters:data-directory}' \
+    --basedir='{{ parameter_dict['mariadb-location'] }}' \
+  && exec '{{ parameter_dict['mariadb-location'] }}/bin/mysqld' \
+    --defaults-file='${my-cnf:rendered}' \
+    "$@"
+rendered = ${directory:services}/mariadb
 
 [logrotate-entry-mariadb]
 recipe = slapos.cookbook:logrotate.d
@@ -257,7 +265,6 @@ parts +=
   logrotate-entry-mariadb
   binary-link
   update-mysql
-  mysqld
   resiliency-exclude-file
   resiliency-after-import-script
   promise