diff --git a/bitnami/mysql/8.0/debian-12/rootfs/opt/bitnami/scripts/libmysql.sh b/bitnami/mysql/8.0/debian-12/rootfs/opt/bitnami/scripts/libmysql.sh index bba9024113366..eb4ff34afe846 100644 --- a/bitnami/mysql/8.0/debian-12/rootfs/opt/bitnami/scripts/libmysql.sh +++ b/bitnami/mysql/8.0/debian-12/rootfs/opt/bitnami/scripts/libmysql.sh @@ -189,35 +189,45 @@ EOF ######################### mysql_exec_initial_dump() { info "MySQL dump master data start..." - mysql -h "$DB_MASTER_HOST" -P "$DB_MASTER_PORT_NUMBER" -u "$DB_MASTER_ROOT_USER" -p"$DB_MASTER_ROOT_PASSWORD" -e 'RESET MASTER;' - databases=("mysql") - if [ -n "$DB_DATABASE" ]; then - databases+=("$DB_DATABASE") - fi - for DB in "${databases[@]}"; do - info "Start dump process database $DB" - if [[ $DB = @(information_schema|performance_schema|sys) ]]; then - info "Skipping default table $DB to be imported" - continue - fi - DUMP_FILE="$DB_DATA_DIR/dump_$DB.sql" - if mysqldump --verbose -h "$DB_MASTER_HOST" -P "$DB_MASTER_PORT_NUMBER" -u "$DB_MASTER_ROOT_USER" -p"$DB_MASTER_ROOT_PASSWORD" "$DB" > "$DUMP_FILE"; then - info "Finish dump database $DB" - info "Ensure database exists $DB" - mysql -u "$DB_MASTER_ROOT_USER" < $FILE_LOCATION + + info "Finish dump databases" + + info "UNLOCK MASTER DATABASES FOR WRITE OPERATIONS..." + mysql -h "$DB_MASTER_HOST" -P "$DB_MASTER_PORT_NUMBER" -u "$DB_MASTER_ROOT_USER" -p"$DB_MASTER_ROOT_PASSWORD" -se 'UNLOCK TABLES;' + + info "Start import dump databases" + mysql_execute < $FILE_LOCATION + info "Finish import dump databases" + + mysql_execute "mysql" < "$DUMP_FILE"; then - info "Finish dump database $DB" - info "Ensure database exists $DB" - mysql -u "$DB_MASTER_ROOT_USER" < $FILE_LOCATION + + info "Finish dump databases" + + info "UNLOCK MASTER DATABASES FOR WRITE OPERATIONS..." + mysql -h "$DB_MASTER_HOST" -P "$DB_MASTER_PORT_NUMBER" -u "$DB_MASTER_ROOT_USER" -p"$DB_MASTER_ROOT_PASSWORD" -se 'UNLOCK TABLES;' + + info "Start import dump databases" + mysql_execute < $FILE_LOCATION + info "Finish import dump databases" + + mysql_execute "mysql" < **Note**: The master database must be only used by this process until the end to avoid missing data. -> **Note**: This process will use "RESET MASTER" on the master database, removing all binary log files that are listed in the index file. It is recommended to make a backup of binary files to avoid possible data loss, in case something goes wrong. ### Configuration file