Advertisement
Guest User

Untitled

a guest
Apr 18th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. sudo -u postgres psql postgres
  2. # login as postgres user
  3.  
  4. \conninfo
  5. # get the current connection infomation
  6.  
  7. alter user "user" with superuser;
  8. # change user "user" to superuser
  9.  
  10. # ======
  11. # Config remote login
  12.  
  13. show hba_file;
  14. # find where is the config file of postgresql
  15. # Allow remote access
  16. # 1. change pg_hba.conf
  17. # eg.
  18. host all all 192.168.1.0 255.255.255.0 trust
  19. # 2. change postgresql.conf
  20. # change listen_addresses
  21. tcpip_socket = true
  22. listen_addresses = '*' # if the firewall block other ports, it's okay to do so
  23. # otherwise, may be bind to certain address so it is more safe
  24. # 3. You might need to change firewall rules to allow traffic
  25. # eg show firewall status (ubuntu)
  26. sudo ufw status verbose
  27. # eg
  28. sudo ufw allow from 192.168.1.0/24 to 74.86.26.69 port 443 proto tcp
  29.  
  30. # ======
  31. # Basic commands
  32. \du # show all users info
  33. \l # list db
  34. \c dbname # connect to db
  35. \d # show db info
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement