安装
1.查找软件包
pacman -Si postgresql
2.安装
pacman -S postgresql
3.初始化数据库
sudo su - postgres -c "initdb --locale en_US.UTF-8 -E UTF8 -D '/var/lib/postgres/data'"
4.启动数据库
systemctl start postgresql
5.创建数据库用户,创建用户数据库
#切换用户
sudo su postgres
#创建数据库用户
createuser --interactive xxx
#创建用户数据库
createdb xxx
6.连接数据库
psql -d xxx
配置远程访问
1.配置pg_hba.conf
# Ipv4 local connections:
host all all 127.0.0.1/5432 trust
#添加一条允许远程访问的ip
host all all 0.0.0.0/0 trust
2.配置postgresql.conf
#开启端口
port 5432