What is the Default Password for PostgreSQL?

本文解答了关于PostgreSQL安装后默认密码的常见疑问,强调PostgreSQL并无预设密码,其默认认证模式为ident,该模式依据操作系统用户名进行验证。文章详细解释了ident模式的工作原理,并演示了如何使用正确的OS用户连接到PostgreSQL。
摘要由CSDN通过智能技术生成

https://www.liquidweb.com/kb/what-is-the-default-password-for-postgresql/

 

What is the Default Password for PostgreSQL?

Posted on August 12, 2015 by J. Mays | Updated: November 14, 2017
Category: Getting StartedTechnical SupportTutorials | Tags: authenticationcentosdatabasefedoraidentpostgrespsqlsystemctlsystemdubuntu

When connecting to PostgreSQL on Linux for the first time many admins have questions, especially if those admins are from the MySQL world.

By default, when PostgreSQL is installed, a postgres user is also added.

If you run the command:

cat /etc/passwd

… you’ll see the postgres user.

 

postgres:x:26:26:PostgreSQL Server:/var/lib/pgsql:/bin/bash

The first question many ask is, “What is the default password for the user postgres?” The answer is easy… there isn’t a default password. The default authentication mode for PostgreSQL is set to ident.

cat /var/lib/pgsql/9.3/data/pg_hba.conf

… you’ll see the authentication mode is ident.

# IPv4 local connections:
host    all              all             127.0.0.1/32             ident
# IPv6 local connections:
host    all              all             ::1/128                  ident

What is the ident authentication method? Well, it works by taking the OS username you’re operating as, and comparing it with the allowed database username(s). There is optional username mapping.

This means that in order to connect to PostgreSQL you must be logged in as the correct OS user. In this case, I am logged into the server as root. When I try to connect to PostgreSQL:

psql

… I get the following error:

psql: FATAL: role "root" does not exist

However, if I become the default PostgreSQL user, postgres:

su - postgres

… then attempt a connection to PostgreSQL:

psql

… I get the correct, valid response!

psql (9.3.9)
Type "help" for help.

postgres=#

Be Sociable, Share!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值