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:

  • Docker container can reach DNS but not resolve hosts
  • How to properly run migrations and seed a docker MySql DB using Entity Framework Core
  • What is the benefit of convoy-glusterfs over pure glusterfs
  • Many docker volumes, each for different user (swarm mode)
  • Network connection between 2 Docker Container (JBOSS/DATABASE)
  • FTP access inside docker for a PHP envrionnement
  • 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

  • Rancher imageUuid not Unique
  • Docker WordPress Nginx Folder Structure?
  • Is it possible to run linux docker image on windows
  • Docker overlay network doesn't clean up removed containers
  • Can I build a Docker container from the CLI against a remote daemon?
  • Bad Substitution Error Installing NVM within Debian-based Docker image
  • 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.