m
no edit summary
mNo edit summary
 
(8 intermediate revisions by the same user not shown)
Line 62: Line 62:


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.
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 new PostgreSQL user account and a new DB ==
Line 87: Line 88:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
$ created -O puser appdb
$ createdb -O puser appdb
</syntaxhighlight>
</syntaxhighlight>




= Usage =
= Usage =
Log into PostgreSQL console using a specific user and DB
<syntaxhighlight lang="bash">
$ sudo -iu puser
$ psql -d appdata -U puser
</syntaxhighlight>
Create a new table
<syntaxhighlight lang="psql">
puser=> CREATE TABLE demo(
id serial PRIMARY KEY,
email VARCHAR (100) UNIQUE NOT NULL,
name  VARCHAR (50) UNIQUE NOT NULL
);
</syntaxhighlight>


{| class="wikitable sortable"
{| class="wikitable sortable"
|+ PostgreSQL  
|+ PostgreSQL console commands
|-
|-
! Command !! Action !! Description or Notes
! Command !! Action !! Description or Notes
Line 100: Line 119:
| class="cli" | \q || Quit ||
| class="cli" | \q || Quit ||
|-
|-
| Example || Example || Example
| class="cli" | \conninfo || Connection information || Get current connection information
|-
|-
| Example || Example || Example
| class="cli" | \d || List || List tables, views, and sequences
|-
| class="cli" | \dt || List tables ||
|}
|}
<code>\q</code>
<syntaxhighlight lang="bash">
</syntaxhighlight>
<syntaxhighlight lang="bash">
</syntaxhighlight>


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
</syntaxhighlight>
</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>


= Resources =
= Resources =


[[Introduction to PostgreSQL for MySQL Users]]
[[Introduction to PostgreSQL for MySQL Users]]