Installing Postgres on Linux Mint

Posted by Richard Lucas on Dec 1 2013

###A Quick Guide

Open up the terminal:

1
$ sudo apt-get install postgresql

Installs Postgresql. This will take a few minutes.

Next:

1
$ sudo su - postgres

This logs you into the database as the postgres user. You will then want to create yourself as a user:

1
$ createuser your_username

Now, at the command prompt under your username, you are able to use createdb and other commands. So, let’s create a quick database and connect to it.

1
$ createdb myFirstDb

Connect to it:

1
$ psql myFirstDb

You will then see a prompt that will look like:

1
myFirstDb=#

The # indicates that you are the superuser, which is most likely if you just installed postgres on your local computer.

Let’s run:

1
myFirstDb=# SELECT Version();

This should go into a new screen on your terminal that should look something like this:

1
2
3
4
5
6
version
-------------------------------------------------------------------------------------------------------
PostgreSQL 9.1.10 on i686-pc-linux-gnu, compiled by gcc (Ubuntu/Linaro 4.8.1-10ubuntu7) 4.8.1, 32-bit
(1 row)
(END)

Type q to exit the screen and go back to the # prompt.

You can run commands from the # prompt using \ notation and the official documentation on commands can be found here: http://www.postgresql.org/docs/9.3/interactive/app-psql.html

If you want a GUI client:

1
$ sudo apt-get install pgadmin3