Postgresql: Difference between revisions

From Objectif Client Inc
Jump to navigation Jump to search
No edit summary
No edit summary
Line 14: Line 14:


=== Manage User ===
=== Manage User ===
** Create Super User
** Create user with login
<pre>CREATE USER username WITH LOGIN SUPERUSER PASSWORD 'thesecret';</pre>
<pre>CREATE ROLE username WITH LOGIN PASSWORD 'mysecret';</pre>


** Provide Superuser to a user
<pre>ALTER ROLE username SUPERUSER </pre>


** List users
<pre>select rolname,rolsuper,rolcanlogin FROM pg_roles; </pre>
=== PgAdmin4===
=== PgAdmin4===



Revision as of 17:15, 17 April 2022

Postgresql

Authorize external connection

    • Modify /etc/postgresql/12/main/postgresql.conf
listen_addresses = '*'
    • Modify /etc/postgresql/12/main/pg_hba.conf
host all all 0.0.0.0/0 md5

Change postgres password

sudo -u postgres psql

then

\password postgres

Manage User

    • Create user with login
CREATE ROLE username WITH LOGIN PASSWORD 'mysecret';
    • Provide Superuser to a user
ALTER ROLE username SUPERUSER 
    • List users
select rolname,rolsuper,rolcanlogin FROM pg_roles; 

PgAdmin4

Url

http://localhost/pgadmin4

Reset Web Password

  • Clear /var/lib/pgamdin folder
  • Reconfigure the web interface
 dpkg-reconfigure pgamin4-apache2