ubuntu 安装 postgres sql

发布时间:2023-05-15 12:03:45
修改时间:2023-05-15 12:04:43
总阅读数:221
今日阅读数:0
昨日日阅读数:0
字数:1303

ubuntu 安装 postgres  sql

安装

添加源

sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update

安装

“postgresql”可以使用“postgresql-14”的方式指定安装版本

sudo apt-get -y install postgresql

修改配置文件

修改配置文件pg_hba.conf

vim /etc/postgresql/14/main/pg_hba.conf

末尾添加

host    all             all             0.0.0.0/0               scram-sha-256

修改配置文件postgresql.conf

vim /etc/postgresql/14/main/postgresql.conf

修改配置

listen_addresses = '*'

修改登陆密码

sudo su postgres
psql
 ALTER USER postgres WITH PASSWORD 'newPassword';

重启服务

systemctl restart postgresql