ubuntu 22.04安裝postgresql
安裝
sudo apt install postgresql
修改
/etc/postgresql/14/main/postgresql.conf
把 listen_addresses = '127.0.0.1'
修改為 listen_addresses = '*'
/etc/postgresql/14/main/pg_hba.conf
添加
host all all 0.0.0.0/0 md5
放到最上面
重啟postgresql
sudo systemctl restart postgresql
創建用戶
從root 用戶切換到 postgres
su postgres
然后
psql
然后創建用戶
create user postgres2 with NOSUPERUSER CREATEDB CREATEROLE LOGIN PASSWORD '123456';
這個時候就可以用ip+端口(5432)+用戶(postgres2) + 密碼(123456) 遠程登錄了。
如果不好使,可以關注一下防火墻是否允許
參考
https://www.postgresql.org/docs/14/sql-createuser.html
https://www.postgresql.org/docs/14/auth-pg-hba-conf.html
https://www.postgresql.org/docs/14/runtime-config-connection.html
posted on 2023-04-20 09:25 cococooder 閱讀(317) 評論(0) 收藏 舉報
浙公網安備 33010602011771號