Import SQL into running mysql container

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?


I just found out that its actually injecting from the local host not the container so i don’t need the copy. Even better! is probably worth a read-through, especially the “Initializing a fresh instance” section.