Solved

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

Posted on 2008-06-17
9
2,515 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 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
 

Author Comment

by:jaisonshereen
ID: 21808505
what is the command to login to postgres without using database name?
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
SQL Command Tool comes with APEX under SQL Workshop. It helps us to make changes on the database directly using a graphical user interface. This helps us writing any SQL/ PLSQL queries and execute it on the database and we can create any database ob…
Steps to create a PostgreSQL RDS instance in the Amazon cloud. We will cover some of the default settings and show how to connect to the instance once it is up and running.
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

757 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now