Skip to content

Instantly share code, notes, and snippets.

@Justintime50
Last active October 10, 2021 06:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Justintime50/6c61b674aa64fb78b102bac2b199892c to your computer and use it in GitHub Desktop.
Save Justintime50/6c61b674aa64fb78b102bac2b199892c to your computer and use it in GitHub Desktop.
Learn how to import or export SQL from a Docker Container

Import or Export SQL from a Docker Container

To export SQL, you must have permissions to do so (AKA: root).

# Importing SQL
docker exec -i CONTAINER_NAME mysql -uUSERNAME -pPASSWORD DATABASE_NAME < MY_FILE.sql

# Exporting SQL
docker exec -i CONTAINER_NAME mysqldump -uroot -p DATABASE_NAME > MY_FILE.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment