Skip to content

Conversation

@an3l
Copy link
Contributor

@an3l an3l commented Feb 19, 2024

  • First commit structuralizes previous example
  • To test the PR run following:
$ sudo rm -rf dump-data/ && mkdir dump-data && sudo chown -R 999:999 dump-data
$ docker compose -f compose-mysql8.0.yml down -v
[+] Running 2/0
 ✔ Volume migration-80_mysqldump  Removed                                                                                                                                                                  0.0s 
 ✔ Volume migration-80_dbdata     Removed 
$ docker compose -f compose-mysql8.0.yml up
  • Check containers
$ docker ps
CONTAINER ID   IMAGE          COMMAND                  CREATED              STATUS                          PORTS                 NAMES
cbcdd1450304   mariadb:lts    "docker-entrypoint.s…"   About a minute ago   Up About a minute (healthy)     3306/tcp              mariadb-migrated-mysql8.0
a3c6dd61ad5c   mariadb:lts    "docker-entrypoint.s…"   About a minute ago   Up About a minute (healthy)     3306/tcp              mariadb-container-dump
cc8c028ddca4   mysql:8.3.0    "docker-entrypoint.s…"   About a minute ago   Up About a minute (healthy)     3306/tcp, 33060/tcp   mysql-container
  • Check logs during services startup
# Dumping files
mariadb-container-dump     | 2024-02-19 13:13:12+00:00 [Note] [Entrypoint]: /usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/dump-mysql.sh
mariadb-container-dump     | MariaDB service started.
mariadb-container-dump     | mysql
mariadb-container-dump     | Remove files if exist
mariadb-container-dump     | Dump and compress MySQL data with changed collation ...
mariadb-container-dump     | Dump and compress MySQL users ...
mariadb-container-dump     | Dump and compress MySQL stats ...
mariadb-container-dump     | Dump and compress MySQL timezones 

# Migrated container
mariadb-migrated-mysql8.0  | 2024-02-19 13:13:33+00:00 [Note] [Entrypoint]: /usr/local/bin/docker-entrypoint.sh: sourcing /docker-entrypoint-initdb.d/migrate-mariadb.sh
mariadb-migrated-mysql8.0  | Extract file
/etc/dump/mysql-dump-data.sql.zst: 1894 bytes                                  
mariadb-migrated-mysql8.0  | Show data in MariaDB
mariadb-migrated-mysql8.0  | Database
mariadb-migrated-mysql8.0  | information_schema
mariadb-migrated-mysql8.0  | mysql
mariadb-migrated-mysql8.0  | performance_schema
mariadb-migrated-mysql8.0  | sys
mariadb-migrated-mysql8.0  | testdb
mariadb-migrated-mysql8.0  | name
mariadb-migrated-mysql8.0  | Bosnia & Herzegovina
  • Or if one wants to check on CLI
# Source of data MySQL 8.0
$ docker exec -it mysql-container mysql -uroot -psecret -e "select * from testdb.countries"
mysql: [Warning] Using a password on the command line interface can be insecure.
+----------------------+
| name                 |
+----------------------+
| Bosnia & Herzegovina |
+----------------------+

# Migrated data to MariaDB
$ docker exec -it mariadb-migrated-mysql8.0 mariadb -uroot -psecret -e "select * from testdb.countries"
+----------------------+
| name                 |
+----------------------+
| Bosnia & Herzegovina |
+----------------------+

Make mariadb-dump a one-shot container
This allows the container to finish once the dump as been made
to allow the next migration to start.

With this, we've used the root user to allow changing of ownership
of the mysqldump volume.

Because of MDEV-20912 being resolved we don't need to manually change
collations.
Copy link
Member

@grooverdan grooverdan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @an3l, I've been a horrible person taking so long on this.
❤️

@grooverdan grooverdan merged commit 2db6eb3 into master Nov 5, 2025
4 of 5 checks passed
@grooverdan grooverdan deleted the anel-mysql8-migration-v2 branch November 5, 2025 07:31
@an3l
Copy link
Contributor Author

an3l commented Nov 5, 2025

Thanks @grooverdan :), no worries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants