Skip to content

Instantly share code, notes, and snippets.

@lacek
Created January 14, 2020 02:44
Show Gist options
  • Save lacek/ad1fcf03c77b3057b642770aec4a5403 to your computer and use it in GitHub Desktop.
Save lacek/ad1fcf03c77b3057b642770aec4a5403 to your computer and use it in GitHub Desktop.
Experiment on upgrading MySQL 5.5 to 5.7 in Docker

Trial of Upgrading MySQL 5.5 to 5.7 in Docker

  1. Start a MySQL 5.5 and load data

    docker run -d --rm --name db55 \
        -v $PWD/my_db:/var/lib/mysql \
        -e 'MYSQL_ROOT_HOST=%' \
        -e 'MYSQL_ROOT_PASSWORD=root' \
        -e 'MYSQL_DATABASE=my_db' \
        -p 8306:3306 mysql:5.5
    
    # load a SQL dump into the db
    
    docker stop db55
    
  2. Start MySQL 5.6 with the data and upgrade

    docker run -d --rm --name db56 \
        -v $PWD/my_db:/var/lib/mysql \
        -e 'MYSQL_ROOT_HOST=%' \
        -e 'MYSQL_ROOT_PASSWORD=root' \
        -e 'MYSQL_DATABASE=my_db' \
        -p 8306:3306 mysql:5.6
    
    docker exec -it db56 mysql_upgrade -uroot -proot
    
    docker restart db56
    
    # check mysqld logs
    docker logs db56
    
    # connect db and check tables
    
    docker stop db56
  3. Start MySQL 5.7 with the data and upgrade

    docker run -d --rm --name db57 \
        -v $PWD/my_db:/var/lib/mysql \
        -e 'MYSQL_ROOT_HOST=%' \
        -e 'MYSQL_ROOT_PASSWORD=root' \
        -e 'MYSQL_DATABASE=my_db' \
        -p 8306:3306 mysql:5.7
    
    docker exec -it db57 mysql_upgrade -uroot -proot
    
    docker restart db57
    
    # check mysqld logs
    docker logs db57
    
    # connect db and check tables
  4. Clean up

    docker stop db57
    docker rm db55 db56 db57
    sudo rm -r $PWD/my_db
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment