diff --git a/src/instance/manager.ts b/src/instance/manager.ts index 908a8a1..660d619 100644 --- a/src/instance/manager.ts +++ b/src/instance/manager.ts @@ -264,6 +264,11 @@ export class InstanceManager { console.log('PostgreSQL is ready, creating database and user...'); + // First, set a password for the postgres superuser + console.log('Setting password for postgres superuser...'); + const postgresPassword = this.generateSecurePassword(); + await this.execAsyncWithLogging(`${psqlPath} -h "${socketDirectory}" -p ${config.spec.network.port} -U postgres -d postgres -c "ALTER USER postgres PASSWORD '${postgresPassword}'"`); + // Create the database console.log(`Creating database: ${config.spec.database.name}`); await this.execAsyncWithLogging(`${psqlPath} -h "${socketDirectory}" -p ${config.spec.network.port} -U postgres -d postgres -c "CREATE DATABASE \\"${config.spec.database.name}\\""`); @@ -444,7 +449,7 @@ export class InstanceManager { const command = [ initdbPath, '-D', config.spec.storage.dataDirectory, - '--auth-local=peer', + '--auth-local=trust', '--auth-host=md5', `--encoding=${config.spec.database.encoding}`, `--locale=${config.spec.database.locale}`, @@ -644,8 +649,8 @@ export class InstanceManager { '# pg_hba.conf generated by PgForge', '# TYPE DATABASE USER ADDRESS METHOD', '', - '# Local connections', - 'local all all peer', + '# Local connections - use md5 for password authentication', + 'local all all md5', '', '# IPv4 connections', ];