postgresql


Improvements requested by Community, Community:

  • This topic would benefit from additional syntax notation, explanation of parameters, or remarks. ×2 - jul 21 at 11:49
    Comments:
    • Add a Version section, describing the major releases of postgresql along with links to release notes. - Community
    • Replace the default remarks section with a descriptive overview of postgresql. - Community

This draft deletes the entire topic.

inline side-by-side expand all collapse all

Examples

  • 0

    In order to install PostgreSQL on OSX, you need to know which versions are currently supported.

    Use this command to see what versions you have available.

    sudo port list | grep "^postgresql[[:digit:]]\{2\}[[:space:]]"
    

    You should get a list that looks something like the following:

    postgresql80                   @8.0.26         databases/postgresql80
    postgresql81                   @8.1.23         databases/postgresql81
    postgresql82                   @8.2.23         databases/postgresql82
    postgresql83                   @8.3.23         databases/postgresql83
    postgresql84                   @8.4.22         databases/postgresql84
    postgresql90                   @9.0.23         databases/postgresql90
    postgresql91                   @9.1.22         databases/postgresql91
    postgresql92                   @9.2.17         databases/postgresql92
    postgresql93                   @9.3.13         databases/postgresql93
    postgresql94                   @9.4.8          databases/postgresql94
    postgresql95                   @9.5.3          databases/postgresql95
    postgresql96                   @9.6beta2       databases/postgresql96
    

    In this example, the most recent version of PostgreSQL that is supported in 9.6, so we will install that.

    sudo port install postgresql96-server postgresql96
    

    You will see an installation log like this:

    --->  Computing dependencies for postgresql96-server
    --->  Dependencies to be installed: postgresql96
    --->  Fetching archive for postgresql96
    --->  Attempting to fetch postgresql96-9.6beta2_0.darwin_15.x86_64.tbz2 from         https://packages.macports.org/postgresql96
    --->  Attempting to fetch postgresql96-9.6beta2_0.darwin_15.x86_64.tbz2.rmd160 from https://packages.macports.org/postgresql96
    --->  Installing postgresql96 @9.6beta2_0
    --->  Activating postgresql96 @9.6beta2_0
    
    To use the postgresql server, install the postgresql96-server port
    
    --->  Cleaning postgresql96
    --->  Fetching archive for postgresql96-server
    --->  Attempting to fetch postgresql96-server-9.6beta2_0.darwin_15.x86_64.tbz2 from https://packages.macports.org/postgresql96-server
    --->  Attempting to fetch postgresql96-server-9.6beta2_0.darwin_15.x86_64.tbz2.rmd160 from https://packages.macports.org/postgresql96-server
    --->  Installing postgresql96-server @9.6beta2_0
    --->  Activating postgresql96-server @9.6beta2_0
    
    To create a database instance, after install do
     sudo mkdir -p /opt/local/var/db/postgresql96/defaultdb
     sudo chown postgres:postgres /opt/local/var/db/postgresql96/defaultdb
     sudo su postgres -c '/opt/local/lib/postgresql96/bin/initdb -D /opt/local/var/db/postgresql96/defaultdb'
    
    --->  Cleaning postgresql96-server
    --->  Computing dependencies for postgresql96
    --->  Cleaning postgresql96
    --->  Updating database of binaries
    --->  Scanning binaries for linking errors
    --->  No broken files found.
    

    The log provides instructions on the rest of the steps for installation, so we do that next.

    sudo mkdir -p /opt/local/var/db/postgresql96/defaultdb
    sudo chown postgres:postgres /opt/local/var/db/postgresql96/defaultdb
    sudo su postgres -c '/opt/local/lib/postgresql96/bin/initdb -D /opt/local/var/db/postgresql96/defaultdb'
    

    Now we start the server:

    sudo port load -w postgresql96-server
    

    Verify that we can connect to the server:

    su postgres -c psql
    

    You will see a prompt from postgres:

    psql (9.6.1)
    Type "help" for help.
    
    postgres=#
    

    Here you can type a query to see that the server is running.

    postgres=#SELECT setting FROM pg_settings WHERE name='data_directory';
    

    And see the response:

                    setting
    ------------------------------------------
    /opt/local/var/db/postgresql96/defaultdb
    (1 row)
    postgres=#
    

    Type \q to quit:

    postgres=#\q
    

    And you will be back at your shell prompt.

    Congratulations! You now have a running PostgreSQL instance on OS/X.

  • Improvements requested by Laurenz Albe:

    • Other: It is specific to certain Linux distributions and does not cover Windows at all. Also, a reference to 9.6 is out of place; that will become obsoletee before you can blink. It might be better to say that the PGDG offers the most current vresions. - jul 22 at 7:15
    0

    On most linux operating systems, postgresql can easily be installed using the package manager. For example on the So called Red Hat family you can just type

    yum install postgresql-server
    

    Into the shell as the super user to get the postgresql server installed. On centos 7 this would give you version 9.2 while on Fedora 22 the installed version will be 9.4

    Similarly on Ubuntu Like operating systems, one would do

    sudo apt-get install postgresql-9.4
    

    If the version that's installed by default is not the one that you want you can use the postgresql yum repository (also known as pgdg ) to get a different version which includes Postgresql 9.6 which is currently in Beta.

I am downvoting this example because it is...

Remarks

This section provides an overview of what postgresql is, and why a developer might want to use it.

It should also mention any large subjects within postgresql, and link out to the related topics. Since the Documentation for postgresql is new, you may need to create initial versions of those related topics.

Versions

VersionRelease Date
9.52016-01-07
9.42014-12-18
9.32013-09-09
9.22012-09-10
9.12011-09-12
9.02010-09-20
8.42009-07-01
8.32008-02-04
8.22006-12-05
8.12005-11-08
8.02005-01-19

Older/outdated version history

7.4 7.3 7.2 7.1 7.0 6.5 6.4 6.3 6.2 6.1 6.0 1.09 1.02 1.01 1.0 0.03 0.02 0.01

Still have question about Introduction to PostgreSQL? Ask Question

How to install PostgreSQL via MacPorts on OSX

0

In order to install PostgreSQL on OSX, you need to know which versions are currently supported.

Use this command to see what versions you have available.

sudo port list | grep "^postgresql[[:digit:]]\{2\}[[:space:]]"

You should get a list that looks something like the following:

postgresql80                   @8.0.26         databases/postgresql80
postgresql81                   @8.1.23         databases/postgresql81
postgresql82                   @8.2.23         databases/postgresql82
postgresql83                   @8.3.23         databases/postgresql83
postgresql84                   @8.4.22         databases/postgresql84
postgresql90                   @9.0.23         databases/postgresql90
postgresql91                   @9.1.22         databases/postgresql91
postgresql92                   @9.2.17         databases/postgresql92
postgresql93                   @9.3.13         databases/postgresql93
postgresql94                   @9.4.8          databases/postgresql94
postgresql95                   @9.5.3          databases/postgresql95
postgresql96                   @9.6beta2       databases/postgresql96

In this example, the most recent version of PostgreSQL that is supported in 9.6, so we will install that.

sudo port install postgresql96-server postgresql96

You will see an installation log like this:

--->  Computing dependencies for postgresql96-server
--->  Dependencies to be installed: postgresql96
--->  Fetching archive for postgresql96
--->  Attempting to fetch postgresql96-9.6beta2_0.darwin_15.x86_64.tbz2 from         https://packages.macports.org/postgresql96
--->  Attempting to fetch postgresql96-9.6beta2_0.darwin_15.x86_64.tbz2.rmd160 from https://packages.macports.org/postgresql96
--->  Installing postgresql96 @9.6beta2_0
--->  Activating postgresql96 @9.6beta2_0

To use the postgresql server, install the postgresql96-server port

--->  Cleaning postgresql96
--->  Fetching archive for postgresql96-server
--->  Attempting to fetch postgresql96-server-9.6beta2_0.darwin_15.x86_64.tbz2 from https://packages.macports.org/postgresql96-server
--->  Attempting to fetch postgresql96-server-9.6beta2_0.darwin_15.x86_64.tbz2.rmd160 from https://packages.macports.org/postgresql96-server
--->  Installing postgresql96-server @9.6beta2_0
--->  Activating postgresql96-server @9.6beta2_0

To create a database instance, after install do
 sudo mkdir -p /opt/local/var/db/postgresql96/defaultdb
 sudo chown postgres:postgres /opt/local/var/db/postgresql96/defaultdb
 sudo su postgres -c '/opt/local/lib/postgresql96/bin/initdb -D /opt/local/var/db/postgresql96/defaultdb'

--->  Cleaning postgresql96-server
--->  Computing dependencies for postgresql96
--->  Cleaning postgresql96
--->  Updating database of binaries
--->  Scanning binaries for linking errors
--->  No broken files found.

The log provides instructions on the rest of the steps for installation, so we do that next.

sudo mkdir -p /opt/local/var/db/postgresql96/defaultdb
sudo chown postgres:postgres /opt/local/var/db/postgresql96/defaultdb
sudo su postgres -c '/opt/local/lib/postgresql96/bin/initdb -D /opt/local/var/db/postgresql96/defaultdb'

Now we start the server:

sudo port load -w postgresql96-server

Verify that we can connect to the server:

su postgres -c psql

You will see a prompt from postgres:

psql (9.6.1)
Type "help" for help.

postgres=#

Here you can type a query to see that the server is running.

postgres=#SELECT setting FROM pg_settings WHERE name='data_directory';

And see the response:

                setting
------------------------------------------
/opt/local/var/db/postgresql96/defaultdb
(1 row)
postgres=#

Type \q to quit:

postgres=#\q

And you will be back at your shell prompt.

Congratulations! You now have a running PostgreSQL instance on OS/X.

Installation or Setup

0

On most linux operating systems, postgresql can easily be installed using the package manager. For example on the So called Red Hat family you can just type

yum install postgresql-server

Into the shell as the super user to get the postgresql server installed. On centos 7 this would give you version 9.2 while on Fedora 22 the installed version will be 9.4

Similarly on Ubuntu Like operating systems, one would do

sudo apt-get install postgresql-9.4

If the version that's installed by default is not the one that you want you can use the postgresql yum repository (also known as pgdg ) to get a different version which includes Postgresql 9.6 which is currently in Beta.

Topic Outline