PostgreSQL upgrade (version 9.6 to version 12)


PostgreSQL (commonly known as Postgres) is a well-known, solid as a rock database. And yes, from time to time it craves for an upgrade too. Today we will learn something about PostgreSQL Windows upgrade from version 9.6 to 12.

The psql upgrade is based on pg_upgrade command. The first step is to install Postgres version 12 and it is available for download on the PostgreSQL official site (visit PostgreSQL). Install the downloaded file and set a familiar Postgres password (in our example we will use the following password: postgres). Since psql 9.6 is also installed on your server, the port on which version 12 will listen will be 5433.

Before we start with the upgrade, stop both databases. Afterward, open command prompt and type: SET PASSWORD=your password. In our example, it would look like this: SET PASSWORD= postgres.

The next step would be data migration. To perform this task, use the following in your command line:

Let's see what these arguments represent:

  1. -d is data directory for the older psql, version 9.6
  2. -D is data directory for the newer version 12 
  3. -b is binary folder for the older psql
  4. -B is binary folder for the newer version 12 psql
  5. -U postgres would be the user which is performing the migration.

When the migration is complete, you can analyze your databases. In your new postgresql.conf file (located in c:\Program Files\PostgreSQL\12) change port to 5432 and start the Postgres 12 service. Do not forget to disable Postgres 9.6 service and, if you are sure that everything went smoothly, delete Postgres 9.6 as well.

And that is all it takes to have your databases running on PostgreSQL 12!

Elasticsearch as Big Data analytics tool
Agile roadmap

Related Posts

By accepting you will be accessing a service provided by a third-party external to


Mailing and Visiting Address:
Soneco d.o.o.
Makenzijeva 24/VI, 11000 Belgrade, Serbia
Phone: +381.11.6356319
Fax: +381.11.2455210 |


linkedin facebook facebook