How to load database in mysql docker container?

After creating the mysql docker container i wanted to load a new database dump to it.
In case you are wondering how to create dockers on you windows machine you can refer my post here .
If you are just testing it you can download a sample mysql database from here .
Once you have downloaded the sample DB unzip it in a folder.
First, copy the database into the container:
$ docker cp mydump.sql c598nvcvc190:/root  # Here c598nvcvc190 is name of database container
Second, Connect to your docker container:
$ docker exec -it c598nvcvc190 /bin/bash
Finally, restore the database dump file into your database “After creating it first”:
# mysql -uroot -prootpassword < /root/mydump.sql
Now you should be able to see the new database listed in mysql.
Be Sociable. Share It. Happy Learning!

No comments:

Post a Comment