postgresqlpostgresql-13

Postgres global .conf file


I manually built postgresql-13.11 on an m1 mac.

When attempting to run either /path/to/postgres/bin/postgres (same for postmaster), i get the following error:

postgres does not know where to find the server configuration file.
You must specify the --config-file or -D invocation option or set the PGDATA environment variable.

which i was able to bypass by running /path/to/postgres/bin/postgres -D /path/to/databaseDir, postgres starts normally.

  1. Does that mean the server can only start for a single database?

Clusters are stored as a directory referred to as base directory.

  1. Does that mean all my databases are stored directly under /path/to/postgresDir / Where exactly is the base directory ?

Solution

  • Once you initiated a database cluster by executing /path/to/postgres/bin/initdb /path/to/databaseDir, you can create as many databases you want in the cluster using the query postgres=# CREATE DATABASE your_database in your default database, and you can connect to that using postgres=# \c your_database.

    You can also create multiple database clusters with their own set of databases by initiating the second database cluster /path/to/postgres/bin/initdb /path/to/databaseDir2 but you have to ensure that they are all isolated and running on different ports.