Solved

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

Posted on 2008-06-17
9
2,530 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

CCModeler offers a way to enter basic information like entities, attributes and relationships and export them as yEd or erviz diagram. It also can import existing Access or SQL Server tables with relationships.
When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

861 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