20 de fev. de 2025
How to Export SQL from PostgreSQL via Terminal + Docker
Here are some step-by-step commands on how to export SQL from the PostgreSQL database via terminal + Docker
1) Enter the Docker machine with the following command
docker exec -it seu_projeto_db_1 bash
2) Then run the command below to find out the directory that will exit:
pwd
3) The next step is to run the export command
pg_dump -U seu_projeto -h localhost -p 5432 -d seu_projeto -f seu_projeto.sql
4) Verify that SQL appears in the file list by running the following command
ls
5) If your_project.sql appears in the list of files, then you must exit the docker machine and run the command to extract this sql from docker
docker cp seu_projeto_db_1:/seu_projeto.sql
Photo the Lukas: https://www.pexels.com/pt-br/foto/codificacao-de-pessoa-no-laptop-574071/