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

MDBF 633: Docker compose file example for MySQL 5.7 migration #551

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions examples/migration-5.7/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
DB_ROOT_PASSWORD='secret'
DB_USER='testuser'
DB_PASSWORD='password'
DB_DATABASE='testdb'
MYSQL_name='mysql-container'
MYSQL_MIGRATE_name='mysql-container-migrated'
16 changes: 16 additions & 0 deletions examples/migration-5.7/compose-migrate-mysql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: "3"
services:
mariadb-from-mysql57:
environment:
MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD}
MYSQL_USER: ${DB_USER}
MYSQL_PASSWORD: ${DB_PASSWORD}
MARIADB_AUTO_UPGRADE: 1
container_name: ${MYSQL_MIGRATE_name}
Copy link
Member

Choose a reason for hiding this comment

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

where is MYSQL_MIGRATE_name from?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From .env file

Copy link
Member

Choose a reason for hiding this comment

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

Why not MARIADB_ROOT_PASSWORD and the other alternative MARIADB_ env vars?

image: mariadb:lts
volumes:
# MySQL data that we want to migrate
- dbdata:/var/lib/mysql

volumes:
dbdata: {}
27 changes: 27 additions & 0 deletions examples/migration-5.7/compose-mysql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
version: "3"

services:
mysql:
environment:
MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD}
MYSQL_USER: ${DB_USER}
MYSQL_PASSWORD: ${DB_PASSWORD}
MYSQL_DATABASE: ${DB_DATABASE}
container_name: ${MYSQL_name}
image: mysql:5.7
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "--silent"]
interval: 5s
timeout: 3s
retries: 2
start_period: 0s
volumes:
# Preload files for MySQL data
- ./mysql:/docker-entrypoint-initdb.d:z
# We have to save MySQL volume that will be used in upgrade
- dbdata:/var/lib/mysql
volumes:
dbdata: {}

networks:
backend:
3 changes: 3 additions & 0 deletions examples/migration-5.7/mysql/mysql-data.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DROP TABLE IF EXISTS countries;
CREATE TABLE countries(name char(20));
INSERT INTO countries values ("Bosnia & Herzegovina");
Loading