How to download sql dump and import it into pg database on local env

Category: SQL :: Published at: 23.02.2023

This is the simple instruction on how to download the dump file with sql database and import it to the local postgreqsql database

1. In the beginning we need to download the database. In this case, i have the PHPMyAdmin tool, so I'm signing in, going inside the database and downloading it as SQL. i need to remember to not export it outside of the database, the correct button is inside the database.

2. When I have dump I need to recreate the database. I'm doing it by running pgAdmin app, removing database and recreating it

3. Now i'm using the console command:

psql -d database_name -f ./file_name.sql

Alternatively:

sudo -u postgres pg_dump -U postgres -d database_name > file.sql

That's it!


- Click if you liked this article

Views: 729