diff options
author | Suren A. Chilingaryan <csa@suren.me> | 2018-03-17 21:07:38 +0100 |
---|---|---|
committer | Suren A. Chilingaryan <csa@suren.me> | 2018-03-17 21:07:38 +0100 |
commit | 14d10bc21087e3734d4e7ac15883c76d0cd19818 (patch) | |
tree | 02600a93e7849e9f9e4ab9399c1258ec36cc2273 /root-galera/usr/share/container-scripts/mysql/init | |
download | mysql-galera-14d10bc21087e3734d4e7ac15883c76d0cd19818.tar.gz mysql-galera-14d10bc21087e3734d4e7ac15883c76d0cd19818.tar.bz2 mysql-galera-14d10bc21087e3734d4e7ac15883c76d0cd19818.tar.xz mysql-galera-14d10bc21087e3734d4e7ac15883c76d0cd19818.zip |
MySQL 5.7 with Galera (produced as combination of standard MySQL container and openshift-mariadb-galera by adfinis-sygroup)
Diffstat (limited to 'root-galera/usr/share/container-scripts/mysql/init')
4 files changed, 66 insertions, 0 deletions
diff --git a/root-galera/usr/share/container-scripts/mysql/init/50-galera-passwd-change.sh b/root-galera/usr/share/container-scripts/mysql/init/50-galera-passwd-change.sh new file mode 100644 index 0000000..2844d5f --- /dev/null +++ b/root-galera/usr/share/container-scripts/mysql/init/50-galera-passwd-change.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +password_change() { +mysql $mysql_flags <<EOSQL + CREATE USER IF NOT EXISTS '${MYSQL_GALERA_USER}'@'localhost'; + SET PASSWORD FOR '${MYSQL_GALERA_USER}'@'localhost' = PASSWORD('${MYSQL_GALERA_PASSWORD}'); + GRANT RELOAD, LOCK TABLES, REPLICATION CLIENT ON *.* TO '${MYSQL_GALERA_USER}'@'localhost'; + UPDATE mysql.user SET Super_Priv='Y', Process_priv='Y' WHERE user='${MYSQL_GALERA_USER}' AND host='localhost'; + FLUSH PRIVILEGES; +EOSQL +} + +password_change +unset -f password_change diff --git a/root-galera/usr/share/container-scripts/mysql/init/51-extradb.sh b/root-galera/usr/share/container-scripts/mysql/init/51-extradb.sh new file mode 100644 index 0000000..c047265 --- /dev/null +++ b/root-galera/usr/share/container-scripts/mysql/init/51-extradb.sh @@ -0,0 +1,14 @@ +extradb() { +for db in "$MYSQL_EXTRADB"; do +mysql $mysql_flags <<EOSQL + GRANT ALL ON \`${db}\`.* TO '${MYSQL_USER}'@'%' ; + FLUSH PRIVILEGES ; +EOSQL +done; +} + +if [ -v MYSQL_EXTRADB ]; then + extradb +fi + +unset -f extradb diff --git a/root-galera/usr/share/container-scripts/mysql/init/52-super.sh b/root-galera/usr/share/container-scripts/mysql/init/52-super.sh new file mode 100644 index 0000000..9e49151 --- /dev/null +++ b/root-galera/usr/share/container-scripts/mysql/init/52-super.sh @@ -0,0 +1,12 @@ +set_super() { +mysql $mysql_flags <<EOSQL + UPDATE mysql.user SET Super_Priv='Y' WHERE user='${MYSQL_USER}' AND host='%'; + FLUSH PRIVILEGES; +EOSQL +} + +if [ -v MYSQL_USER_PRIV_SUPER ]; then + set_super +fi + +unset -f set_super diff --git a/root-galera/usr/share/container-scripts/mysql/init/53-pma.sh b/root-galera/usr/share/container-scripts/mysql/init/53-pma.sh new file mode 100644 index 0000000..5644b8f --- /dev/null +++ b/root-galera/usr/share/container-scripts/mysql/init/53-pma.sh @@ -0,0 +1,26 @@ +set_pma() { +mysql $mysql_flags <<EOSQL + CREATE USER IF NOT EXISTS 'pma'@'%' IDENTIFIED BY '${MYSQL_PMA_PASSWORD}'; + ALTER USER 'pma'@'%' IDENTIFIED BY '${MYSQL_PMA_PASSWORD}'; + + GRANT USAGE ON mysql.* TO 'pma'@'%'; + GRANT SELECT ( + Host, User, Select_priv, Insert_priv, Update_priv, Delete_priv, + Create_priv, Drop_priv, Reload_priv, Shutdown_priv, Process_priv, + File_priv, Grant_priv, References_priv, Index_priv, Alter_priv, + Show_db_priv, Super_priv, Create_tmp_table_priv, Lock_tables_priv, + Execute_priv, Repl_slave_priv, Repl_client_priv + ) ON mysql.user TO 'pma'@'%'; + + GRANT SELECT ON mysql.db TO 'pma'@'%'; + #GRANT SELECT ON mysql.host TO 'pma'@'%'; + GRANT SELECT (Host, Db, User, Table_name, Table_priv, Column_priv) ON mysql.tables_priv TO 'pma'@'%'; + GRANT SELECT, INSERT, UPDATE, DELETE ON phpmyadmin.* TO 'pma'@'%'; +EOSQL +} + +if [ -v MYSQL_PMA_PASSWORD ]; then + set_pma +fi + +unset -f set_pma |