Skip to main content

安装



https://www.postgresql.org/download/linux/redhat/



sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-aarch64/pgdg-redhat-repo-latest.noarch.rpm
sudo dnf -qy module disable postgresql
sudo dnf install -y postgresql17-server
sudo /usr/pgsql-17/bin/postgresql-17-setup initdb
sudo systemctl enable postgresql-17
sudo systemctl start postgresql-17

默认端口
5432

# 切换用户为postgres
su postgres

登录到控制台
psql

修改密码
ALTER USER postgres WITH PASSWORD 'Aq123456';

修改用户名
ALTER ROLE "postgres" RENAME TO "postgres007";
ALTER ROLE "postgres007" RENAME TO "postgres";
ALTER USER postgres RENAME TO postgres007;


创建用户
CREATE ROLE "arick" SUPERUSER CREATEDB CREATEROLE LOGIN REPLICATION BYPASSRLS;

ALTER USER "arick" WITH PASSWORD 'Aq123456';

CREATE USER "arick" WITH SUPERUSER CREATEDB CREATEROLE LOGIN PASSWORD 'Aq123456';

登录 -d postgres 默认数据库
psql -h localhost -p 5433 -U arick -d postgres

vim /var/lib/pgsql/17/data/postgresql.conf

修改 port
port = 15432

# 文件末尾添加
listen_addresses='*'


vim /var/lib/pgsql/17/data/pg_hba.conf
# 添加所有ip都能访问
host all all 0.0.0.0/0

# 重新启动pg服务
systemctl restart postgresql-17