Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/instance/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}\\""`);
Expand Down Expand Up @@ -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}`,
Expand Down Expand Up @@ -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',
];
Expand Down