Debian 10安装Postgres14
Overview
说明
默认debian10安装的Postgresql版本是11,因项目需要,需要升级到Postgresql 14。
安装步骤
1$ sudo apt update && sudo apt upgrade
2
3$ sudo apt -y install gnupg2 wget vim
4
5$ sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
6
7$ sudo wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
8
9$ sudo apt -y update
10
11$ sudo apt install postgresql-14
12
13# 查看版本
14$ sudo -u postgres psql -c "SELECT version();"
15
16# 查看进程状态
17$ systemctl status postgresql
初始化
1$ sudo vi /etc/postgresql/14/main/postgresql.conf
2# 修改项
3listen_addresses = '*' # what IP address(es) to listen on;
4
5$ sudo vi /etc/postgresql/14/main/pg_hba.conf
6
7# IPv4 local connections:
8#host all all 127.0.0.1/32 scram-sha-256
9host all all 0.0.0.0/0 scram-sha-256
10
11$ sudo service postgresql restart
12
13
14# 设置postgres默认密码为123456
15$ sudo -u postgres psql
16
17ALTER Role postgres WITH PASSWORD '123456'; #注意命令后面又分号