diff options
Diffstat (limited to 'root-galera/usr/share/container-scripts/mysql/galera-common.sh')
-rw-r--r-- | root-galera/usr/share/container-scripts/mysql/galera-common.sh | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/root-galera/usr/share/container-scripts/mysql/galera-common.sh b/root-galera/usr/share/container-scripts/mysql/galera-common.sh deleted file mode 100644 index b4d90e5..0000000 --- a/root-galera/usr/share/container-scripts/mysql/galera-common.sh +++ /dev/null @@ -1,61 +0,0 @@ -#!/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 <<EOSQL - CREATE USER '${MYSQL_USER}'@'%' IDENTIFIED BY '${MYSQL_PASSWORD}'; -EOSQL - fi - - if [ -v MYSQL_DATABASE ]; then - log_info "Creating database ${MYSQL_DATABASE} ..." - mysqladmin $admin_flags create "${MYSQL_DATABASE}" - if [ -v MYSQL_USER ]; then - log_info "Granting privileges to user ${MYSQL_USER} for ${MYSQL_DATABASE} ..." -mysql $mysql_flags <<EOSQL - GRANT ALL ON \`${MYSQL_DATABASE}\`.* TO '${MYSQL_USER}'@'%' ; - FLUSH PRIVILEGES ; -EOSQL - fi - fi - - if [ -v MYSQL_ROOT_PASSWORD ]; then - log_info "Setting password for MySQL root user ..." - # for 5.6 and lower we use the trick that GRANT creates a user if not exists - # because IF NOT EXISTS clause does not exist in that versions yet - if [[ "$MYSQL_VERSION" > "5.6" ]] ; then - mysql $mysql_flags <<EOSQL - CREATE USER IF NOT EXISTS 'root'@'%'; -EOSQL - fi -mysql $mysql_flags <<EOSQL - GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '${MYSQL_ROOT_PASSWORD}' WITH GRANT OPTION; -EOSQL - fi - log_info 'Initialization finished' - - # remember that the database was just initialized, it may be needed on other places - export MYSQL_DATADIR_FIRST_INIT=true -} |