Created
October 24, 2019 20:02
-
-
Save gokman/ec932cb929a1b9c8bd9b946c42b62c25 to your computer and use it in GitHub Desktop.
create mysql container with data via docker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--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