[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to check the database name of postgres in my linux machine

Posted on 2008-06-17
9
Medium Priority
?
2,575 Views
Last Modified: 2013-12-16
How to check the database name of postgres in my linux machine

i need to take the backup for that i have to give dabase name
i only know username and password ...

this is the command :
pg_dump -Ft -b mydb > db.tar

one more doubt is ..

which one i need to use db.tar
or
db.tz

or
db.out

0
Comment
Question by:jaisonshereen
  • 5
  • 4
9 Comments
 
LVL 9

Accepted Solution

by:
sanjooz earned 2000 total points
ID: 21808103
Depends on what you want.

If you want the output to be a tar file then use
pg_dump -Ft -b mydb > db.tar

If you want the ordinary output use .out file

http://www.postgresql.org/docs/7.4/static/app-pgdump.html
0
 

Author Comment

by:jaisonshereen
ID: 21808190
Ok thanks !

how to find out my db name? ... i have already installed database in my server..how to find the dbname?
0
 
LVL 9

Expert Comment

by:sanjooz
ID: 21808279
Well the database name is the one you created. If you do not know all the databases in postgres, login locally to postgres by issuing command psql on command line.

then at the postgres prompt do a \l (that is a backward slash and el). It will show you a list of databases.
0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 

Author Comment

by:jaisonshereen
ID: 21808505
what is the command to login to postgres without using database name?
0
 
LVL 9

Expert Comment

by:sanjooz
ID: 21808738
login locally to postgres by issuing command <B> psql </B>on command line.

psql
0
 

Author Comment

by:jaisonshereen
ID: 21808749
its taking root as database and giving error :

 psql
psql: FATAL:  database "root" does not exist

Open in new window

0
 
LVL 9

Expert Comment

by:sanjooz
ID: 21809143
That is because you are logged in to console as root. Log in as a normal user and then use psql command
0
 

Author Comment

by:jaisonshereen
ID: 21810716
i didnt have any other  user credentials
0
 
LVL 9

Expert Comment

by:sanjooz
ID: 21812070
When you installed postgres, you must have created postgres user. Look in your /etc/passwd, or you could run this command

cat /etc/passwd | cut -d":" -f1

then login as as postgres user : su postgres
and then :  psql
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lotus Notes has been used since a very long time as an e-mail client and is very popular because of it's unmatched security. In this article we are going to learn about  RRV Bucket corruption and understand various methods to Fix "RRV Bucket Corrupt…
What we learned in Webroot's webinar on multi-vector protection.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question