Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker-compose script for simple data migration from MySQL 8.0 to MariaDB #559

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

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 |
+----------------------+

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.

3 participants