Reputation: 483
I'm trying to import a database to my mysql container in Docker but I had some errors with sql file.
I used this code to import the data:
docker exec -i MYCONTAINER mysql -uMYUSER -pMYPASS@ -f -D MYDATABASE < MYFILE.sql
But still returns a error about syntax from file, I can't open this file cause is too huge, the only way to do this is with mysqldump. Anybody else have a method to import this file?
Thanks in advance!
Upvotes: 0
Views: 796
Reputation: 1431
When you run the command docker exec <container_name> <command>
, the command
will be executed inside the container and since the MYFILE.sql
does not exist inside that container, it will definitely throw errors.
Another problem is that the container is already created, there is no way for you to mount the file inside unless you want to recreate the container.
Here is a workaround for this problem:
sql
file into the containerdocker cp ./MYFILE.sql MYCONTAINER:/tmp/MYFILE.sql
/tmp/MYFILE.sql
, you can execute your command likedocker exec -i MYCONTAINER mysql -uMYUSER -pMYPASS@ -f -D MYDATABASE < /tmp/MYFILE.sql
Upvotes: 1