Debian/Ubuntu 下修改postgresql默认密码

本文介绍如何为刚安装好的PostgreSQL数据库的postgres用户设置初始密码。通过使用sudo su postgres命令切换到postgres用户,并利用psql命令行工具进行密码设置。

刚安装好postgresql时postgres用户是没有初始密码的。执行以下命令以postgre身份登陆数据库并修改密码:

sudo su postgres
psql -U postgres
alter user postgres with password 'new-password';
\q 


# 添加官方源(如前所述) curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | \ sudo gpg --dearmor -o /usr/share/keyrings/postgresql-archive-keyring.gpg echo "deb [signed-by=/usr/share/keyrings/postgresql-archive-keyirng.gpg] http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" | \ sudo tee /etc/apt/sources.list.d/pgdg.list sudo apt update sudo apt install -y postgresql-16 deb [signed-by=/usr/share/keyrings/postgresql-archive-keyirng.gpg] http://apt.postgresql.org/pub/repos/apt focal-pgdg main Hit:1 http://mirrors.tencentyun.com/ubuntu focal InRelease Hit:2 http://mirrors.tencentyun.com/ubuntu focal-updates InRelease Hit:3 http://mirrors.tencentyun.com/ubuntu focal-backports InRelease Hit:4 http://mirrors.tencentyun.com/ubuntu focal-security InRelease Hit:5 https://download.docker.com/linux/ubuntu focal InRelease Hit:6 http://ppa.launchpad.net/git-core/ppa/ubuntu focal InRelease Hit:7 https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/8.0 InRelease Ign:8 http://apt.postgresql.org/pub/repos/apt focal-pgdg InRelease Err:9 http://apt.postgresql.org/pub/repos/apt focal-pgdg Release 404 Not Found [IP: 198.18.0.12 80] Hit:10 https://packages.redis.io/deb focal InRelease Reading package lists... Done E: The repository 'http://apt.postgresql.org/pub/repos/apt focal-pgdg Release' does not have a Release file. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details. Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package postgresql-16
最新发布
11-13
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值