diff --git a/cmake/environment/mysql.template b/cmake/environment/mysql.template
new file mode 100644
index 0000000000000000000000000000000000000000..32495113689be93702027d89579c686891d8d685
--- /dev/null
+++ b/cmake/environment/mysql.template
@@ -0,0 +1 @@
+export MYSQL_HOME=${mysql_home}
diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt
index 90578ba483bdb66ecaf50d57e825dbc072a92f15..4ea36f31e8a3572a452a12e657df75954b7a414d 100644
--- a/externals/CMakeLists.txt
+++ b/externals/CMakeLists.txt
@@ -1478,6 +1478,8 @@ LCGPackage_Add(
              IF LCG_COMP MATCHES clang THEN
              -DPLUGIN_TOKUDB=NO
              ENDIF
+  INSTALL_COMMAND ${MAKE} install
+          COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/mysql_postinstall.sh <INSTALL_DIR>
   DEPENDS Boost bison jemalloc libevent zlib libxml2 libedit lz4 zeromq msgpackc
 )
 
diff --git a/externals/mysql_postinstall.sh b/externals/mysql_postinstall.sh
new file mode 100755
index 0000000000000000000000000000000000000000..8eecb0d9ab9b372aaf4ebe0ca836223671e3a5c8
--- /dev/null
+++ b/externals/mysql_postinstall.sh
@@ -0,0 +1,23 @@
+#!/usr/bin/env bash
+
+if test "x$1" = "x" ; then
+    echo "mysql_postinstall: Install directory undefined!"
+    exit 1
+else
+    MYSQL_HOME=$1
+fi
+
+# Create $MYSQL_HOME/my.cnf config file and set basedir as install dir
+if !(test -d $MYSQL_HOME); then 
+    echo "mysql_postinstall: Given install directory is not a directory."
+    exit 1
+fi
+if test -f "$MYSQL_HOME/my.cnf"; then
+    echo "mysql_postinstall: my.cnf already exists, appending new basedir"
+    echo "basedir = $MYSQL_HOME" >> "$MYSQL_HOME/my.cnf"
+else
+    echo "mysql_postinstall: Creating file $MYSQL_HOME/my.cnf" 
+    echo "basedir = $MYSQL_HOME" > "$MYSQL_HOME/my.cnf"
+fi
+
+exit 0