Guest User

Untitled

a guest
Jul 23rd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. This is a simple way of importing MySQL database in Docker.
  2.  
  3. In you Dockerfile you must have a shared folder. Shared folder is a directory in your host machine that is mounted to Docker instance.
  4.  
  5. Put the exported sql file in the shared folder.
  6.  
  7. Login to your Docker instance via docker exec -it DOCKER_CONTAINER_ID bin/bash.
  8.  
  9. Login to MySQL via mysql -u USERNAME -p.
  10.  
  11. While in MySQL CLI, create a database via create database DB_NAME;.
  12.  
  13. While in MySQL CLI, use the database you just created via use DB_NAME;.
  14.  
  15. While in MySQL CLI, import the sql file via source /path/to/file.sql.
  16.  
  17. Done
Add Comment
Please, Sign In to add comment