Solved

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

Posted on 2008-06-17
9
2,534 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 9

Accepted Solution

by:
sanjooz earned 500 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

733 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