First of all, let’s check basic of how to Export Postgres database in Ubuntu. There is a standalone application call pg_dump. And also this, not a psql command, this should run is bash. To use this we have to use authentication for a postgres user.
I usually use
sudo -u postgres psql
to log into psql, so I don’t have to give a password for postgres user. So How can I give authentication to pg_dump.
First of all, you have to change user into postgres without password?
sudo -i -u postgres
Now you can see your username is changed is bash.
let’s say you have database name school, so you command should be like below
let’s say you have database name school, so you command should be like below
pg_dump -U postgres school school.sql;
Now is the tricky part Where is the school.sql file? Why don’t we ask it from bash?
type pwd in the terminal, then you will see something like this
/var/lib/postgresql
/var/lib/postgresql
Go there and you will see you SQL dump
Happy coding guys.
Happy coding guys.
No comments:
Post a Comment