1

Given:

$which psql
/Library/PostgreSQL/12/bin/psql
$which createdb
/Library/PostgreSQL/12/bin/createdb

Recently I created a database:

$createdb -U postgres postgres
Password: 

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?

Kevin Meredith
  • 559
  • 1
  • 7
  • 14

1 Answers1

2

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.

jjanes
  • 42,332
  • 3
  • 44
  • 54