Create custom database and user at the time of cluster initialization

Hi All,
Is there a way to create custom database and username during postgresql cluster initialization?

Hello Richa,

There is no direct way to create the custom database and username during Postgresql cluster initialization, but you can create custom databases post cluster initialization.

By default, the new database will be created by cloning the standard system database ‘template1’. A different template can be specified by writing ‘TEMPLATE name’.

For example, You have DB1 and DB2, these two databases, and if you want to create a custom database CUSTOMDB from DB1, then you can create it by using the parameter TEMPLATE.


Note: You can also insert the data into the template1 database as it’s a default template.

I’ve included the below URL for more information about the CREATE DATABASE command.


1 Like