Postresql Client and Version Mismatch

All we need is an easy explanation of the problem, so here it is.


$which psql
$which createdb

Recently I created a database:

$createdb -U postgres postgres

However, I don’t understand why the server version varies from the client.

$psql -U postgres
Password for user postgres: 
psql (12.1, server 9.6.2)
Type "help" for help.

How can I create the server on 12.1 as well?

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

createdb doesn’t create a new database instance (aka ‘cluster’, unfortunately, as that term has grown other uses). It just creates a new database in an already running instance, same as the CREATE DATABASE SQL command does.

To create a new instance use initdb or pg_ctl initdb.

You clearly already have a 9.6 instance created and running. You should probably figure out why and what is in it, and either shut it down, shut it down and delete it, or upgrade it. You could leave it running and pick a new port of your new instance, but that is likely to create even more confusion of the same sort you already have.

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply