Skip to content

Instantly share code, notes, and snippets.

@gokman
Created October 24, 2019 20:02
Show Gist options
  • Save gokman/ec932cb929a1b9c8bd9b946c42b62c25 to your computer and use it in GitHub Desktop.
Save gokman/ec932cb929a1b9c8bd9b946c42b62c25 to your computer and use it in GitHub Desktop.
create mysql container with data via docker
--create container
docker run --name {container name} -p 3306:3306 -e MYSQL_ROOT_HOST=% -e MYSQL_ROOT_PASSWORD={root password} -d {mysql image with tag}
--copy files to the container
docker cp create_db.sql {container name}:/create_db.sql
docker cp insert_db.sql {container name}:/insert_db.sql
-go into the container
docker exec -it {container name} /bin/bash
--import sql files
mysql -uroot -p < create_db.sql
mysql -uroot -p {db name} < insert_db.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment