# PostgreSQL 安装
参考文档:https://www.postgresql.org/download/ (opens new window)
以 Debian10 为例,其他系统请看官方文档,与 Debian10 类似,其他 Linux 系统请看官方文档。
# 添加 apt 源
sudo touch /etc/apt/sources.list.d/pgdg.list
sudo vim /etc/apt/sources.list.d/pgdg.list
1
2
2
写入内容
/etc/apt/sources.list.d/pgdg.list
deb http://apt.postgresql.org/pub/repos/apt/ buster-pgdg main
1
安装证书
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
1
# 安装
sudo apt-get update
sudo apt-get install postgresql-12
1
2
2
# 设置 PostgreSQL 密码
sudo -u postgres psql
1
ALTER USER postgres WITH PASSWORD 'password';
1
# 创建新用户和数据库
CREATE ROLE "danmu" LOGIN PASSWORD 'danmu';
CREATE DATABASE "danmu"
WITH
OWNER = "danmu"
ENCODING = 'UTF8'
;
1
2
3
4
5
6
7
2
3
4
5
6
7