赞
踩
注意这个流程的环境为EXT4!!!
其他文件系统请参阅:PostgreSQL ArchLinux
## 安装pip
sudo pacman -S python-pip
sudo mkdir /var/lib/pgadmin
sudo mkdir /var/log/pgadmin
sudo chown $USER /var/lib/pgadmin
sudo chown $USER /var/log/pgadmin
## 如果有安装conda
conda create -n pgadmin
conda activate pgadmin
pip install pgadmin4 --break-system-packages
## 如果没安装conda
python -m venv pgadmin4
source pgadmin4/bin/activate
pip install pgadmin4 --break-system-packages
## 安装PostgreSQL sudo pacman -S postgresql sudo -iu postgres ## 初始化配置 initdb -D /var/lib/postgres/data ## 创建用户 createuser --interactive ## 创建数据库 createdb 数据库名称 ## 启动数据库服务 ## 1. 开机自启 sudo systemctl enable --now postgresql ## 1.1 关闭自启 sudo systemctl disable postgresql ## 2. 现在启动但是开机不自启 sudo systemctl start postgresql ## 3. 查看状态 sudo systemctl status postgresql
注意这里初始化的PostgreSQL并不会有任何认证要求,全部都是 trust ,即不需要密码就可以访问数据库
需要如下修改来启用密码认证
## 编辑器打开 配置文件pg_hba.conf
sudo vim /var/lib/postgres/data/pg_hba.conf
到最底下,可以看到内容
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all trust
host replication all 127.0.0.1/32 trust
host replication all ::1/128 trust
将所有 trust 改为 md5
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all md5
# 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 md5
host replication all 127.0.0.1/32 md5
host replication all ::1/128 md5
若想要进行远程连接,还需要添加如下内容
host all all 0.0.0.0/0 md5
pgadmin4
然后会有提示在
http://127.0.0.1:5050启动服务
然后进入浏览器点击
效果如下:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。