Docker Community Forums

Share and learn in the Docker community.

Import SQL into running mysql container


(Sthompso) #1

I can’t figure out how to import a sql file into an already running mysql container. The original sql file is on the host machine and i copied it over like this:

docker cp database_schema.sql my-mysql:/database_schema.sql

I can then see it in the root dir on the container but when i try to import it I get a “No such file or directory”.

[jenkins@or1010050215222 ~]$ docker exec -i my-mysql ls | grep .sql
[jenkins@or1010050215222 ~]$ docker exec -i my-mysql mysql < database_schema.sql
-bash: database_schema.sql: No such file or directory

What am I doing wrong?


(Sthompso) #2

I just found out that its actually injecting from the local host not the container so i don’t need the copy. Even better!

(David Maze) #3 is probably worth a read-through, especially the “Initializing a fresh instance” section.