Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sudo -u postgres psql postgres
- # login as postgres user
- \conninfo
- # get the current connection infomation
- alter user "user" with superuser;
- # change user "user" to superuser
- # ======
- # Config remote login
- show hba_file;
- # find where is the config file of postgresql
- # Allow remote access
- # 1. change pg_hba.conf
- # eg.
- host all all 192.168.1.0 255.255.255.0 trust
- # 2. change postgresql.conf
- # change listen_addresses
- tcpip_socket = true
- listen_addresses = '*' # if the firewall block other ports, it's okay to do so
- # otherwise, may be bind to certain address so it is more safe
- # 3. You might need to change firewall rules to allow traffic
- # eg show firewall status (ubuntu)
- sudo ufw status verbose
- # eg
- sudo ufw allow from 192.168.1.0/24 to 74.86.26.69 port 443 proto tcp
- # ======
- # Basic commands
- \du # show all users info
- \l # list db
- \c dbname # connect to db
- \d # show db info
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement