Tools
Upgrading PostgreSQL9 to 13 For Non-US Locales Fails
This article details an issue where upgrading PostgreSQL 9 to 13 for a non-US locales fails with: lc_collate values for database "postgres" do not match: old "English_United States.1252", new "English_Canada.1252"
First published date
Last published date
Overview
The upgrade to WHD to v12.7.7 completes successfully can the application runs fine on PostgreSQL 9.
However when attempting to finish instructions to upgrade the database to PostgreSQL13 , the PowerShell script fails with the following error and the service will cannot be started.
Example Error: lc_collate values for database "postgres" do not match: old "English_United States.1252", new "English_Canada.1252"
Note: This issue does not affect Web Help Desk environments running on Linux.
Product section
Cause
Resolution
2. Create a batch file using a text editor with the script below and Save it As: setupDatabaseForUpgrade.bat
- You can save this file inside C:\Program Files\WebHelpDesk
@echo on :: Web Help Desk :: Copyright (c) SolarWinds Worldwide, LLC :: :: Utility to setup the Web Help Desk database if "%~1"=="" goto :usage set WHD_HOME=%~1 set WHD_LOGFILE=%WHD_HOME%\log\setup.log if exist "%WHD_HOME%\pgsql13\data\base" goto :databaseExist echo Creating new database with fix... >> "%WHD_LOGFILE%" :: The type of characters set the database will use (Encoding). SET PG_ENCODING=UTF-8 :: The database cultural preferences regarding alphabets, sorting, number formatting, etc (locale). SET PG_LOCALE=English_United States.1252 :: The Admin user that will be created with the database. SET PG_DATABASE_ADMIN=whd :: Type of authentication that allow that anyone who use existing user username to connect to the database. SET PG_NO_AUTH=trust :: Type of authentication that use username and password to authenticate the user to connect the database. :: The given password will be encrypted using md5 algorithm and will the given user. SET PG_MD5_AUTH=md5 :: Type of authentication that use username and password to authenticate the user to connect the database. :: The given password will be encrypted using scram-sha-256 algorithm and will the given user. SET PG_NEW_AUTH=scram-sha-256 ::The for the new database. SET PG_DATABASE_PATH=%WHD_HOME%\pgsql13\data ::Create the database folder and give the user permissions to create the database in the folder and use the log file. if not exist "%PG_DATABASE_PATH%" mkdir "%PG_DATABASE_PATH%" cacls.exe "%PG_DATABASE_PATH%" /E /G %username%:F cacls.exe "%WHD_LOGFILE%" /E /G %username%:F :: This command will create the database. :: Because it is a database upgrade, the admin user doesn't require a password so to not supply password, the database will be initialized without authentication and afterwords the authentication will be set. "%WHD_HOME%\pgsql13\bin\pg_ctl" init -D "%PG_DATABASE_PATH%" -o "-U %PG_DATABASE_ADMIN% -E %PG_ENCODING% -A %PG_NO_AUTH% --locale=""%PG_LOCALE%""" >> "%WHD_LOGFILE%" 2>&1 :: pg_ctl : program that used to initialize, start, stop, or control a PostgreSQL database. :: init : pg_ctl mode for creating new database (wrapper for the creating database process). :: -D : The path to the database (that will be created). :: -o : To supply additional paramters that will neeed for the database initialization. :: -U : The admin user that will be created for the database (The main admin user that support the postgresql database). :: -E : The encoding that the database will use. :: -A : The authentication type that the database will use (no authentication is used so the admin user could be created without password). :: --locale : The locale that the database will use. :: This will add another configuration that the password for the postgresql new users will be encrypted using the new algorithm scram-sha-256. :: The configuration file that responsible for postgresql database settings <webhelpdesk>\pgsql13\data\postgresql.conf. echo password_encryption = %PG_NEW_AUTH% >> "%PG_DATABASE_PATH%\postgresql.conf" :: This will set that the only way to connect to the database is with local ip using password authentication with md5 algorithm. ::The Configuration file that is responsible for the client authentications <webhelpdesk>\pgsql13\data\pg_hba.conf. echo host all all 127.0.0.1/32 md5 > "%PG_DATABASE_PATH%\pg_hba.conf" echo host all all ::1/128 md5 >> "%PG_DATABASE_PATH%\pg_hba.conf" echo Installing and starting the PostgreSQL service... >> "%WHD_LOGFILE%" :: start the database service call "%WHD_HOME%\pgsql13\bin\installService.bat" "%WHD_HOME%" goto :eof :usage echo Web Help Desk Database creator fix for postgresql upgrade. echo Usage: %0 ^<webhelpdesk_program_directory^> echo. goto:eof :: Message to delete the folder database if exist. :databaseExist echo Delete the previous postgresql 13.3 database folder: "%WHD_HOME%\pgsql13\data". goto:eof
3. Open CMD and run as admin
4. Navigate to "C:\Program Files\WebHelpDesk" and run the script giving it the path to the web help desk folder: Run command: setupDatabaseForUpgrade.bat "C:\Program Files\WebHelpDesk"
5. A new database will be created in <WebHelpDesk>\pgsql13\data
These configurations will be placed inside <WebHelpDesk>\pgsql13\data\postgresql.conf.
6. For reference, follow the steps in this article, How to upgrade Web Help Desk to version 12.7.7 using PostgreSQL as the Database . *Note: Scroll to the section where it discusses the upgradedatabase.bat steps.
The upgrade script will run and should finish successfully.
Note: If a client upgrades to WHD 12.7.8 from a version prior to 12.7.7 without upgrading PostgreSQL9 to PostgreSQL13, WHD 12.7.8 will not recognize PostgreSQL9. Make sure to upgrade PostgreSQL9 to PostgreSQL13 first in WHD 12.7.7 before upgrading to 12.7.8