[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2585
  • Last Modified:

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

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
jaisonshereen
Asked:
jaisonshereen
  • 5
  • 4
1 Solution
 
sanjoozCommented:
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
 
jaisonshereenAuthor Commented:
Ok thanks !

how to find out my db name? ... i have already installed database in my server..how to find the dbname?
0
 
sanjoozCommented:
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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
jaisonshereenAuthor Commented:
what is the command to login to postgres without using database name?
0
 
sanjoozCommented:
login locally to postgres by issuing command <B> psql </B>on command line.

psql
0
 
jaisonshereenAuthor Commented:
its taking root as database and giving error :

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

Open in new window

0
 
sanjoozCommented:
That is because you are logged in to console as root. Log in as a normal user and then use psql command
0
 
jaisonshereenAuthor Commented:
i didnt have any other  user credentials
0
 
sanjoozCommented:
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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now