{"id":183,"date":"2026-05-11T07:55:20","date_gmt":"2026-05-11T14:55:20","guid":{"rendered":"https:\/\/choice.work\/?p=183"},"modified":"2026-05-11T07:55:47","modified_gmt":"2026-05-11T14:55:47","slug":"choice-log-no-1778481744-postgresql-18-initial-configuration","status":"publish","type":"post","link":"https:\/\/choice.work\/?p=183","title":{"rendered":"Choice log no. 1778481744 &#8211; PostgreSQL 18 Initial Configuration"},"content":{"rendered":"<p>Service account<br>\nDatabase cluster<br>\nConfiguration files<\/p>\n<p>Service Account \u2013 Dedicated operating system user that runs the server daemon. Always use a dedicated account. Limit access to PostgreSQL data. <\/p>\n<ul>\n<li>Items managed by the server<\/li>\n<li>Data files<\/li>\n<li>Configuration files<\/li>\n<\/ul>\n<p>Should not own the executables or binaries.<\/p>\n<ul>\n<li>Prevents modification by the server process<\/li>\n<li>Avoids malicious activity if it\u2019s compromised<\/li>\n<\/ul>\n<p>Pre-packaged installations ensure a suitable user<\/p>\n<p>Database Cluster \u2013 Collection of databases managed by one server, can be one or multiple databases. Initialize database storage with initdb.<\/p>\n<p>Sets the \u201cdata directory\u201d<\/p>\n<ul>\n<li>Data files<\/li>\n<li>Default for configuration files<\/li>\n<\/ul>\n<p>initidb creates default databases<\/p>\n<ul>\n<li><strong>postgres<\/strong> \u2013 primary default database. Good for utilites, users, and third-party applications to use, as the database is standard database that all expect to be there.<\/li>\n<li><strong>Template1<\/strong> is what the system copies when creating new database. Anything added to this database will be available in all new databases.<\/li>\n<li><strong>Template0<\/strong> \u2013 remains a clean default copy in case a new is needed that does not have the usual user modifications.<\/li>\n<\/ul>\n<p>initdb also sets defaults, such as local, sort order, and encoding<\/p>\n<p>Configuration Files \u2013 The primary method for configuring PostgreSQL is going to be configuration files. This is where a number of parameters that control the system behavior. Configuration parameters within these are not arbitrary text. The parameters do have defined data types and syntax rules. The values in these files can be overridden with SQL or the shell to provide temporary or user-specific modifications. Normally located in the \u201cdata directory\u201d (this is configurable). There are multiple files. Some of the primary ones are postgresql.conf (primary source of configuration). There is also pg_hba.conf that contains client authentication rules and pg_indent.conf, which maps operating system users to PostgreSQL users.<\/p>\n<p>Primary method to set parameters<\/p>\n<ul>\n<li>Defined data types and syntax rules<\/li>\n<li>Can be overwritten with SQL or the shell<\/li>\n<ul>\nNormally located in the \u201cdata directory\u201d.<br>\nMultiple files\n<ul>\n<li>postgresql.conf<\/li>\n<li>pg_hba.conf<\/li>\n<li>pg_ident.conf<\/li>\n<\/ul>\n<p>Changes typically require a reload or service restart<\/p>\n<p>Validate user:<br>\n<strong>id postgres<\/strong><br>\nuid=110(postgres) gid=112(postgres) groups=112(postgres),110(ssl-cert)<\/p>\n<p>Switch over to the user:<br>\n<strong>sudo -i -u postgres<\/strong><\/p>\n<p>Verify the default directory that was created using initdb:<br>\npsql -c \u201cSHOW data_directory;\u201d<\/p>\n<p>psql -c \u201cSHOW data_directory;\u201d<br>\n       data_directory<br>\n\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2013<br>\n \/var\/lib\/postgresql\/18\/main<br>\n(1 row)<\/p>\n<p>-TBC<\/p>\n<\/ul><\/ul><nav class='o2-post-footer-actions'><ul class='o2-post-footer-action-row'><li class='o2-post-footer-action'><a href=\"https:\/\/choice.work\/?p=183#respond\" title=\"Reply\"  class=\"o2-post-reply o2-reply genericon  genericon-reply\"  data-action=\"reply\"  data-actionstate=\"default\" >Reply<\/a><\/li><\/ul><div class='o2-post-footer-action-likes'><\/div><ul class='o2-post-footer-action-row'><\/ul><\/nav>","protected":false},"excerpt":{"rendered":"<p>Service account Database cluster Configuration files Service Account \u2013 Dedicated operating system user that runs the server daemon. Always use a dedicated account. Limit access to PostgreSQL data. Items managed by the server Data files Configuration files Should not own the executables or binaries. Prevents modification by the server process Avoids malicious activity if it\u2019s [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-183","post","type-post","status-publish","format-standard","hentry","category-choice","author-choice"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/choice.work\/index.php?rest_route=\/wp\/v2\/posts\/183","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/choice.work\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/choice.work\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/choice.work\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/choice.work\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=183"}],"version-history":[{"count":2,"href":"https:\/\/choice.work\/index.php?rest_route=\/wp\/v2\/posts\/183\/revisions"}],"predecessor-version":[{"id":185,"href":"https:\/\/choice.work\/index.php?rest_route=\/wp\/v2\/posts\/183\/revisions\/185"}],"wp:attachment":[{"href":"https:\/\/choice.work\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=183"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/choice.work\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=183"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/choice.work\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=183"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}