Ubuntu 20.04LTS x PostgresQL
發表於 : 2021-03-22, 16:19
參考文件:
安裝
https://www.digitalocean.com/community/ ... untu-20-04
設定遠端控制
https://www.server-world.info/en/note?o ... esql12&f=2
安裝
遠端控制
安裝
https://www.digitalocean.com/community/ ... untu-20-04
設定遠端控制
https://www.server-world.info/en/note?o ... esql12&f=2
安裝
代碼: 選擇全部
sudo apt install postgresql postgresql-contrib
sudo -i -u postgres
createuser --interactive
Enter name of role to add: *rolename*
Shall the new role be a superuser? (y/n) *y*
createdb *dbname*
//建議rolename=dbname
代碼: 選擇全部
vi /etc/postgresql/12/main/postgresql.conf
# line 59: uncomment and change
listen_addresses = '*'
vi /etc/postgresql/12/main/pg_hba.conf
# add to the end
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all peer
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all peer
host replication all 127.0.0.1/32 md5
host replication all ::1/128 md5
# specify network range you allow to connect on [ADDRESS] section
# if allow all, specify [0.0.0.0/0]
host all all 10.0.0.0/24 md5
systemctl restart postgresql
代碼: 選擇全部
psql -d *dbname*
db=> \password
Enter new password:
Enter it again:
testdb=> \q