PostgreSQL: Difference between revisions

1,332 bytes added ,  13 October 2023
m
m →‎Initial set-up: adding of usage section
Line 56: Line 56:


postgres=#
postgres=#
</syntaxhighlight>
= Configuration =
In order to force password when logging into postgresql console change <code>ident</code> to <code>scram-sha-256</code> in <code>/var/lib/pgsql/data/pg_hba.conf</code> for IP local connections entries.  This is the HBA (Host-based Authentication) configuration file for PostgreSQL.  Restart afterwards.
== Create a new PostgreSQL user account and a new DB ==
Create a Linux user account
<syntaxhighlight lang="bash">
$ sudo useradd puser
$ sudo passwd puser
</syntaxhighlight>
log in as the admin PostgreSQL user
<syntaxhighlight lang="bash">
$ sudo -iu postgres
</syntaxhighlight>
create a new PostgreSQL role for puser Linux user
<syntaxhighlight lang="bash">
$ createuser --interactive --pwprompt
</syntaxhighlight>
while still logged in as postgres user (admin PostgreSQL user) create a new database named appdb for puser
<syntaxhighlight lang="bash">
$ created -O puser appdb
</syntaxhighlight>
</syntaxhighlight>


Line 66: Line 98:
! Command !! Action !! Description or Notes
! Command !! Action !! Description or Notes
|-
|-
| <code>\q</code> || Quit ||
| class="cli" | \q || Quit ||
|-
|-
| Example || Example || Example
| Example || Example || Example
Line 73: Line 105:
|}
|}
<code>\q</code>
<code>\q</code>
<syntaxhighlight lang="bash">
</syntaxhighlight>
<syntaxhighlight lang="bash">
</syntaxhighlight>
<syntaxhighlight lang="bash">
</syntaxhighlight>
<syntaxhighlight lang="bash">
</syntaxhighlight>
<syntaxhighlight lang="bash">
</syntaxhighlight>
<syntaxhighlight lang="bash">
</syntaxhighlight>
<syntaxhighlight lang="bash">
</syntaxhighlight>
<syntaxhighlight lang="bash">
</syntaxhighlight>


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">