How to restore a .sql.gz dump on a Docker MySQL instance?

I have a dump which was taken from a machine on which Docker is NOT installed. The format is .sql.gz – my question is how do I restore this on my Docker MySQL instance?

Able to access MySQL from command line:

  • Setting up Jetty Runner with custom Cert in Docker Build File
  • How to change timezone of postgreSQL 9.5 on docker?
  • How to use kvm in a Centos 6 docker container via docker machine
  • php-fpm process hight memory usage, and the host jammed
  • Dockerized nodes of elasticsearch cluster in EC2, production environment
  • How to include modified configuration files in a docker image?
  • docker run -it --link first-mysql:mysql --rm mysql sh -c 'exec mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD"'

    NOT able to restore the dump using this:

    docker exec -i first-mysql mysql -uroot -ppassword < db_dump.sql

  • How to use docker-compose with theano image?
  • Conductor container can't be found. Run `ansible-container build` first
  • docker commit running container
  • Query MySql database in Docker
  • How to run Docker on Ubuntu 15.04?
  • Can't connect to Postgres container with Docker Compose from Sequelize
  • 2 Solutions collect form web for “How to restore a .sql.gz dump on a Docker MySQL instance?”

    Basic syntax is:

    gunzip dump.sql.gz
    docker exec -i container_name mysql -uroot -proot < dump.sql

    Or copy dunp.sql into a volume go into the conatainer and start mysql there

    docker exec -ti container_name bash
    mysql < /volume_dir/dump.sql

    The rest in mysql syntax.

    1. Because logging in from root wasn’t an issue, log into MySQL using root.
    2. Create another user with all the privileges, a kind of equivalent to root.
    3. Flush privieleges.

    docker exec -i container_name mysql -uloader -ploader < dump.sql

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.