10.2. Connecting to a database

To connect to a database, you can use the psql passing the name of the database you would like to connect to on the command line. If you do not specify a databae to connect to by default, you will connect to your personal database named the same as your login. Complete documentation on the psql utility can be accessed via its man page.

10.2.1. Connecting to your own database


you@labhost:~$ psql 
Password: [your account password here]
Welcome to psql 7.4.12, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help on internal slash commands
       \g or terminate with semicolon to execute query
       \q to quit

you=> \q
you@labhost:~$ 

10.2.2. Connecting to someone else's database (or a project db)

By default you can connect to any database, however you will not be able to read/write to other user's tables unless they have specifically granted you permission.


you@labhost:~$ psql projectdb
Password: [your account password here]
Welcome to psql 7.4.12, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help on internal slash commands
       \g or terminate with semicolon to execute query
       \q to quit

projectdb=> \q
you@labhost:~$