Score:1

PostgresSQL upgrade from 9.6 to 10 on Windows fails when using pg_upgrade (fe_sendauth: no password supplied)

cn flag

Part of the work moving from Windows 2012 to 2019 involves upgrading the current install of Postgres from 9.6 to 10. I'm trying to use pg_upgrade and after some struggle with file permissions I have managed to start the process with the command

pg_upgrade.exe -b "c:/Program Files/PostgreSQL/9.6/bin" -B "d:/PostgreSQL/10/bin" -d "D:/PostgreSQL/9.6/data" -D "D:/PostgreSQL/10/data" --old-port=5432 --new-port=5433 -U postgres -v --check

It starts fine, but after a while it fails like this

"d:/PostgreSQL/10/bin/pg_ctl" -w -l "pg_upgrade_server.log" -D "D:/PostgreSQL/10/data" -o "-p 5433 -b -c synchronous_commit=off -c fsync=off -c full_page_writes=off -c vacuum_defer_cleanup_age=0 " start >> "pg_upgrade_server_start.log" 2>&1

connection to database failed: fe_sendauth: no password supplied
could not connect to target postmaster started with the command:
"d:/PostgreSQL/10/bin/pg_ctl" -w -l "pg_upgrade_server.log" -D "D:/PostgreSQL/10/data" -o "-p 5433 -b -c synchronous_commit=off -c fsync=off -c full_page_writes=off -c vacuum_defer_cleanup_age=0 " start

But if I try to run the command by itself, it starts without any issues. I have updated the pg_hba.conf-file so I can issue psql -U postgres -host 5433 without being prompted for password. Other than that I cannot find anything of value in the pg_upgrade*.log files.

Score:1
es flag
Max

on windows there are two things necessary to do before starting pg_upgrade

  1. enable "passwordless" authentication by editing pg_hba.conf replacing md5 or whatever other method by trust in both ipv4 & v6 sections
# TYPE  DATABASE        USER            ADDRESS                 METHOD

# IPv4 local connections:
#host    all             all             127.0.0.1/32            md5
host    all             all             127.0.0.1/32            trust
# IPv6 local connections:
#host    all             all             ::1/128                 md5
host    all             all             ::1/128                 trust
  1. command must be run under the same user as the database superuser (postgres)

    create a local user postgres and give him admin rights. don't forget to also grant full control right to postgres\data folder in both databases then run cmd.exe from this user (as administrator)

at last , run the command from a location where postgres can read/write log files

run the most recent version of pg_upgrade.

you only need these parameters

d:\PostgreSQL\10\bin\pg_upgrade.exe -b "c:\Program Files\PostgreSQL\9.6\bin" -B "d:\PostgreSQL\10\bin" -d "D:\PostgreSQL\9.6\data" -D "D:\PostgreSQL\10\data"

edit: to improve security, postgres can run without admin privileges but require run as batch job & service privilege. steps :

  • stop postgresql service
  • create local or domain user
  • add user to backup operator group (or log on as batch job right)
  • edit local security policy : security setting->user rights asssignment ->Log on as a service (add your user here)
  • edit service logon user and replace system by your dedicated user
  • change postgres home directory's access right to allow rw of your user.
  • start postgresql service
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.