# PostgreSQL Dump

**URL:** <https://www.ruby-forum.com/t/postgresql-dump/163107>\
**Category:** Ruby\
**Created:** [March 17, 2009, 12:36pm UTC](https://www.ruby-forum.com/t/postgresql-dump/163107 "2009-03-17T12:36:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![saravanankrishnan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f9ae1b/32.png) [@saravanankrishnan](https://www.ruby-forum.com/u/saravanankrishnan)\
**Post date:** [March 17, 2009, 12:36pm UTC](https://www.ruby-forum.com/t/postgresql-dump/163107/1 "2009-03-17T12:36:05Z")

</div>

Hi all,

I’m using following command to take dump from my sql database.

pg\_dump -h localhost -U postgres dbname \> dump.sql

Whenever i trying to run this command in command prompt, it always  
asking password.

Here my query is,

if i write this command in a separate ruby file how can i give password  
in that command.

in my sql, we can use  
mysqldump -h #{host} -u #{user} -p#{pwd} dbname \> dump.sql  
if use like that it wont ask password anymore. but how is it possible in  
postgres.

Thanks in Advance  
Saravanan K

---

<div class="post-metadata">

**Author:** ![saravanankrishnan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f9ae1b/32.png) [@saravanankrishnan](https://www.ruby-forum.com/u/saravanankrishnan)\
**Post date:** [March 17, 2009, 1:27pm UTC](https://www.ruby-forum.com/t/postgresql-dump/163107/2 "2009-03-17T13:27:01Z")

</div>

Saravanan K. wrote:

> Hi all,
> 
> I’m using following command to take dump from my sql database.
> 
> pg\_dump -h localhost -U postgres dbname \> dump.sql
> 
> Whenever i trying to run this command in command prompt, it always  
> asking password.
> 
> Here my query is,
> 
> if i write this command in a separate ruby file how can i give password  
> in that command.
> 
> in my sql, we can use  
> mysqldump -h #{host} -u #{user} -p#{pwd} dbname \> dump.sql  
> if use like that it wont ask password anymore. but how is it possible in  
> postgres.
> 
> Thanks in Advance  
> Saravanan K

Hi folks,

I fixed that issue thanks  
refered link

> **[34.16. The Password File](https://www.postgresql.org/docs/8.1/libpq-pgpass.html)**
>
> 34.16. The Password File The file .pgpass in a user's home directory can contain passwords to be used if the connection …

Thanks
