Here is how we connect to Postgres


Install PostgreSQL on Linux

We are installing PostgreSQL on Ubuntu Linux. Make sure that you have an internet connection enabled and you have administrative privileges.

Start terminal window in your Ubuntu system and execute the following command :

sudo apt-get install postgresql

It will ask for administrative password and then proceed with the installation. The installation process is not much interactive. Only once it asks you “Do you wan to continue?”. Press Y and installation will continue. As soon as the installation is finished, it will take you to the command prompt again. The instillation process also installs PostgreSQL client. The following pictorial is taken while installing PostgreSQL in Ubuntu.

install postgresql ubuntu

Change the PostgreSQL postgres user password

The default user for PostgreSQL is “postgres”. First thing you need to do after you successfully installed PostgreSQL, is to change the password for the “postgres” user. For doing so, run the following command, which will take you to the PostgreSQL command line.

sudo -u postgres psql postgres

The following pictorial is taken after we ran the above command.

postgresq commandline ubuntu

Now run the following command to be prompted to supply password for “postgres” database role.

\password postgres

The following pictorial is taken after we ran the above command.

postgresql change password ubuntu

To exit the PostgreSQL command prompt, type Contrl+D.

Install pgAdmin III – GUI to manage PostgreSQL

Run the following command to install pgadmin3.

sudo apt-get install pgadmin3

The installation process starts and after asking once “Do you want to continue?” it continues. Press y when it asks so. The following pictorial is taken while running the above command.

install pgadmin3 ubuntu

You can start pgadmin III from Application > Programming > pgadmin III.

pgadmin3 ubuntu

We will use this tool often to manage PostgreSQL in the upcoming tutorials. That is all for now about how to install PostgreSQL and pgadmin3 in Ubuntu. If you have any queries and or suggestions, please use our comment section. We will now move to the next section of this document and see, how to install PostgreSQL and pgadmin III in Windows 7.

after this : fill in your new password into the password col in photo1 attached

here localhost in the host column is for connecting to the computer

# in photo 2 , see arrow ; click on the new database and the dormant SQL icon on the the top gets active, it is here that we can type queries.

note:pgadmin3 is the GUI for postgres;hence it is essential for proper function of pgadmin3

source:http://www.w3resource.com/PostgreSQL/install-postgresql-on-linux-and-windows.phpImage

photo1

photo 2

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s