From 14d10bc21087e3734d4e7ac15883c76d0cd19818 Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Sat, 17 Mar 2018 21:07:38 +0100 Subject: MySQL 5.7 with Galera (produced as combination of standard MySQL container and openshift-mariadb-galera by adfinis-sygroup) --- .../share/container-scripts/mysql/galera-common.sh | 61 ++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 root-galera/usr/share/container-scripts/mysql/galera-common.sh (limited to 'root-galera/usr/share/container-scripts/mysql/galera-common.sh') diff --git a/root-galera/usr/share/container-scripts/mysql/galera-common.sh b/root-galera/usr/share/container-scripts/mysql/galera-common.sh new file mode 100644 index 0000000..b4d90e5 --- /dev/null +++ b/root-galera/usr/share/container-scripts/mysql/galera-common.sh @@ -0,0 +1,61 @@ +#!/bin/bash + +source ${CONTAINER_SCRIPTS_PATH}/common.sh + +# Initialize the MySQL database (create user accounts and the initial database) +function initialize_galera_database() { + log_info 'Initializing database ...' + if [[ "$MYSQL_VERSION" < "5.7" ]] ; then + # Using --rpm since we need mysql_install_db behaves as in RPM + log_info 'Running mysql_install_db ...' + mysql_install_db --rpm --datadir=$MYSQL_DATADIR + else + log_info "Running mysqld --initialize-insecure ..." + ${MYSQL_PREFIX}/libexec/mysqld --wsrep-on=OFF --wsrep-provider=none --initialize-insecure --datadir=$MYSQL_DATADIR --ignore-db-dir=lost+found "$@" + fi + + start_local_mysql --wsrep-on=OFF --wsrep-provider=none "$@" + + if [ -v MYSQL_RUNNING_AS_SLAVE ]; then + log_info 'Initialization finished' + return 0 + fi + + # Do not care what option is compulsory here, just create what is specified + if [ -v MYSQL_USER ]; then + log_info "Creating user specified by MYSQL_USER (${MYSQL_USER}) ..." +mysql $mysql_flags < "5.6" ]] ; then + mysql $mysql_flags <