diff options
author | Suren A. Chilingaryan <csa@suren.me> | 2018-03-21 22:00:26 +0100 |
---|---|---|
committer | Suren A. Chilingaryan <csa@suren.me> | 2018-03-21 22:00:26 +0100 |
commit | 823f5325df405286024cdf2a985732baabc0981f (patch) | |
tree | 3274e3e970c6ddbbedc97cdaeb55a060a7f6d310 /root-galera/usr/share/container-scripts/mysql/galera-common.sh | |
parent | 9d9925ec86bb779c60655bbf487d7921f22a36eb (diff) | |
download | mysql-galera-823f5325df405286024cdf2a985732baabc0981f.tar.gz mysql-galera-823f5325df405286024cdf2a985732baabc0981f.tar.bz2 mysql-galera-823f5325df405286024cdf2a985732baabc0981f.tar.xz mysql-galera-823f5325df405286024cdf2a985732baabc0981f.zip |
Add Dockerfile for simple Master/Slave replication and add more parametrization
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 -} |