Ferro's Gitbook
  • README
  • DevOps
    • Grafana_Cloud
  • OpenWrt
    • DHCP_DNS
    • GLiNet
    • boot
    • captive_portal
    • luci
    • mwan3
    • radius
    • theme
    • wireless
  • apps
    • web
  • BSD
    • Mac
  • Cloud
    • aws
    • azure
    • cf
    • gcp
    • github
    • ibm_bluemix
    • Pricing
  • container
    • docker
    • Kubernetes
    • podman
  • db
    • InfluxDB
    • loki
    • MySQL & MariaDB
    • Oracle
    • PostgreSQL
  • dev
    • AHK
    • BI
    • LBS
    • ML
    • android
    • editor
    • flutter_web
    • git
    • go
    • HTML5/BS
    • j2ee
    • js
    • js_grid
    • js_vue
    • jupyter
    • ocaml
    • powershell
    • py
    • py_GUI
    • Django
    • shell
    • snippets
    • uni
    • vba
    • wechat.zh
    • wechat_mp.zh
  • elec
    • 3D Printing
    • AC
    • MOSFET
    • battery
    • boost
    • bulk
    • metal
    • simulator
  • hw
    • GPU
    • PCI
    • arduino
    • Bluetooth
    • ent
    • Pinout
    • x86_AMD
    • x86_intel
  • linux
    • Test System
    • X
    • arch
    • fs
    • kernel
    • Memory
    • nw
    • Linux Services
    • Systemd
    • text
  • ms
    • vscode
    • windows
    • wsl
  • multimedia
    • Blender
    • audio
    • blender
    • graphics
    • home
  • nw
    • L3
    • L3_IPv6
    • SDN
    • VPN
    • dns
    • hw
    • Low Level
    • mikrotik
    • mwan
    • Openflow
    • OVS
    • pfsense
    • ppp
    • proxy
    • tsocks
    • pxe
    • Security
    • TCP
  • phone
    • Mi
    • android
  • Storage(SW)
  • vt
    • Intel GVT-g
    • PVE
    • QEMU
    • VDI
    • hyper-v
    • kube
    • libvirt
    • OpenStack
  • Web
    • IBM_MQ
    • IBM_Websphere
    • SSL
    • Apache/IBM_IHS
    • blockchain
    • caddy
    • j2ee
    • nginx
    • static_site
Powered by GitBook
On this page
  • Info
  • Config
  • pgadmin
  • Commands
  • user
  • db

Was this helpful?

Edit on Git
  1. db

PostgreSQL

PreviousOracleNextdev

Last updated 4 years ago

Was this helpful?

Info

SELECT version();
SELECT now();

Config

SHOW config_file;       -- /var/lib/postgresql/data/postgresql.conf
SHOW data_directory;    -- /var/lib/postgresql/data
SHOW hba_file;          -- /var/lib/postgresql/data/pg_hba.conf
    -- host-based authentication
    -- https://www.postgresql.org/docs/current/static/auth-pg-hba-conf.html
SHOW ident_file;        -- /var/lib/postgresql/data/pg_ident.conf
    -- user name mapping: SYSTEM-USERNAME PG-USERNAME
SHOW external_pid_file;

pgadmin

docker run -p 80:80 \
-e "PGADMIN_DEFAULT_EMAIL=user@domain.com" \
-e "PGADMIN_DEFAULT_PASSWORD=SuperSecret" \
-d dpage/pgadmin4

DB->'Schemas'->'public'->'Tables'->right click table->'View/Edit Data'->'All Rows'

Commands

user

SELECT usename FROM pg_user;
CREATE USER fzinfz;
\password fzinfz
ALTER USER fzinfz WITH SUPERUSER;
\du
    -- list user/role

db

CREATE database tutorial;
\c tutorial
psql -U postgres -h localhost -d tutorial

https://www.postgresql.org/docs/current/static/app-psql.html
https://www.postgresql.org/docs/current/static/runtime-config-file-locations.html
Info
Config
pgadmin
Commands
user
db