Skip to content

Commit

Permalink
mdev-35569 attempt
Browse files Browse the repository at this point in the history
needs update to remove bits.

saving to file is ugly

only partially functional with skip-tz

11.7 and 10.11 errors

2024-12-17 05:25:00+00:00 [Note] [Entrypoint]: Securing system users (equivalent to running mysql_secure_installation)
2024-12-17  5:25:00 0 [Warning] mariadbd: io_uring_queue_init() failed with ENOSYS: check seccomp filters, and the kernel version (newer than 5.1 required)
2024-12-17  5:25:00 0 [Warning] InnoDB: liburing disabled: falling back to innodb_use_native_aio=OFF
ERROR: 1698  Access denied for user 'boot'@'connecting host'
2024-12-17  5:25:00 0 [ERROR] Aborting
  • Loading branch information
grooverdan committed Dec 17, 2024
1 parent a6b360f commit ab8cecf
Showing 1 changed file with 36 additions and 22 deletions.
58 changes: 36 additions & 22 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,10 @@ docker_init_database_dir() {
mariadbdArgs+=("$arg")
fi
done
local init_db_file=
init_db_file=$(mktemp)
docker_setup_db
printf "FLUSH PRIVILEGES;\n%s" "$db_init" > "$init_db_file"
mariadb-install-db "${installArgs[@]}" "${mariadbdArgs[@]}" \
--cross-bootstrap \
--skip-test-db \
Expand All @@ -251,7 +255,10 @@ docker_init_database_dir() {
--skip-log-bin \
--expire-logs-days=0 \
--loose-innodb_buffer_pool_load_at_startup=0 \
--loose-innodb_buffer_pool_dump_at_shutdown=0
--loose-innodb_buffer_pool_dump_at_shutdown=0 \
--extra-file="${init_db_file}"
rm "$init_db_file"

mysql_note "Database files initialized"
}

Expand Down Expand Up @@ -476,10 +483,8 @@ docker_setup_db() {
fi
fi

mysql_note "Securing system users (equivalent to running mysql_secure_installation)"
# tell docker_process_sql to not use MARIADB_ROOT_PASSWORD since it is just now being set
# --binary-mode to save us from the semi-mad users go out of their way to confuse the encoding.
docker_process_sql --dont-use-mysql-root-password --database=mysql --binary-mode <<-EOSQL
# M10.5/6 local db_init=
read -r -d '' db_init <<-EOSQL || true
-- Securing system users shouldn't be replicated
SET @orig_sql_log_bin= @@SESSION.SQL_LOG_BIN;
SET @@SESSION.SQL_LOG_BIN=0;
Expand All @@ -504,6 +509,10 @@ docker_setup_db() {
${changeMasterTo}
EOSQL
mysql_note "Securing system users (equivalent to running mysql_secure_installation)"
# tell docker_process_sql to not use MARIADB_ROOT_PASSWORD since it is just now being set
# --binary-mode to save us from the semi-mad users go out of their way to confuse the encoding.
# M10.5/6 docker_process_sql --dont-use-mysql-root-password --database=mysql --binary-mode <<< "$db_init"
}

# create a new installation
Expand Down Expand Up @@ -539,26 +548,31 @@ docker_mariadb_init()
fi
docker_init_database_dir "$@"

mysql_note "Starting temporary server"
docker_temp_server_start "$@"
mysql_note "Temporary server started."
shopt -s nullglob
local initdb_files=( /docker-entrypoint-initdb.d/* )
shopt -u nullglob
if [ ${#initdb_files[@]} -gt 0 ] || [ -n "${MARIADB_ROOT_PASSWORD_HASH}" ]; then
mysql_note "Starting temporary server"
docker_temp_server_start "$@"
mysql_note "Temporary server started."

docker_setup_db
docker_process_init_files "${initdb_files[@]}"
# Wait until after /docker-entrypoint-initdb.d is performed before setting
# root@localhost password to a hash we don't know the password for.
if [ -n "${MARIADB_ROOT_PASSWORD_HASH}" ]; then
mysql_note "Setting root@localhost password hash"
docker_process_sql --dont-use-mysql-root-password --binary-mode <<-EOSQL
SET @@SESSION.SQL_LOG_BIN=0;
SET PASSWORD FOR 'root'@'localhost'= '${MARIADB_ROOT_PASSWORD_HASH}';
EOSQL
fi

docker_setup_db
docker_process_init_files /docker-entrypoint-initdb.d/*
# Wait until after /docker-entrypoint-initdb.d is performed before setting
# root@localhost password to a hash we don't know the password for.
if [ -n "${MARIADB_ROOT_PASSWORD_HASH}" ]; then
mysql_note "Setting root@localhost password hash"
docker_process_sql --dont-use-mysql-root-password --binary-mode <<-EOSQL
SET @@SESSION.SQL_LOG_BIN=0;
SET PASSWORD FOR 'root'@'localhost'= '${MARIADB_ROOT_PASSWORD_HASH}';
EOSQL
mysql_note "Stopping temporary server"
docker_temp_server_stop
mysql_note "Temporary server stopped"
fi

mysql_note "Stopping temporary server"
docker_temp_server_stop
mysql_note "Temporary server stopped"

echo
mysql_note "MariaDB init process done. Ready for start up."
echo
Expand Down

0 comments on commit ab8cecf

Please sign in to comment.