From 834a6abdc85e52a8a542b8f58ab40af9c05dff6d Mon Sep 17 00:00:00 2001 From: coolneng Date: Fri, 8 Jan 2021 01:22:02 +0100 Subject: [PATCH] Initialize MySQL if the data directory is missing --- env/mysql.nix | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/env/mysql.nix b/env/mysql.nix index e7adb56..0ed93fb 100644 --- a/env/mysql.nix +++ b/env/mysql.nix @@ -12,9 +12,12 @@ in mkShell { shellHook = '' trap "kill 0" EXIT - [ -d ${data_dir} ] || mkdir ${data_dir} - mysqld --datadir="${data_dir}" --socket="${socket}" --initialize-insecure + + if [ ! -d ${data_dir} ]; then + mysqld --datadir="${data_dir}" --socket="${socket}" --initialize-insecure + fi + mysqld --datadir="${data_dir}" --socket="${socket}" --skip-networking --skip-mysqlx & sleep 1