Skip to content

Migrate a Database with different credentials than postgres #113

Open
@Basti-Fantasti

Description

@Basti-Fantasti

I wanted to (or have to) migrate a database from version 16 to version 17.
It seems as in the original there is no database user "postgres" available.

According to the configuration of the original application, the database user is dbroot instead of postgres and the password is a quite random string.
Is there a way to pass in these credentials into your migration tool, too?

Because when trying to run the migration script on this database, I get the following error:
The original database data folder has been copied to the 16/data folder as needed

Commands:

OLD='16'
NEW='17'
docker run --rm -v "$PWD":/var/lib/postgresql "tianon/postgres-upgrade:$OLD-to-$NEW" --link

Output:

The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /var/lib/postgresql/17/data ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default "max_connections" ... 100
selecting default "shared_buffers" ... 128MB
selecting default time zone ... Etc/UTC
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... initdb: warning: enabling "trust" authentication for local connections
initdb: hint: You can change this by editing pg_hba.conf or using the option -A, or --auth-local and --auth-host, the next time you run initdb.
ok


Success. You can now start the database server using:

    pg_ctl -D /var/lib/postgresql/17/data -l logfile start

Performing Consistency Checks
-----------------------------
Checking cluster versions                                     ok

connection to server on socket "/var/lib/postgresql/.s.PGSQL.50432" failed: FATAL:  role "postgres" does not exist


could not connect to source postmaster started with the command:
"/usr/lib/postgresql/16/bin/pg_ctl" -w -l "/var/lib/postgresql/17/data/pg_upgrade_output.d/20250122T110645.796/log/pg_upgrade_server.log" -D "/var/lib/postgresql/16/data" -o "-p 50432 -b  -c listen_addresses='' -c unix_socket_permissions=0700 -c unix_socket_directories='/var/lib/postgresql'" start
Failure, exiting

The basic test with migrating from PG16 to PG17 as written in your README file worked flawlessly. So I assume it has to be related to the settings of the source database.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions