PostgreSQL Remote Connection Configuration Management/account password Assignment (FIX: Fatal error: User "Postgres" Ident authentication failed)

Source: Internet
Author: User
Tags postgresql psql



Problem: Fatal error: User "Postgres" Ident authentication failed



Note: This is because there is no remote access configured and authentication method has not changed, only need to change the use of account password authentication.



Workaround: Locate pg_hba.conf (Find/-name pg_hba.conf), change the ident of method to MD5, and change the IP port to 0.0.0.0/0, or the desired IP address. After the modification is completed, the direct reload can be.






Special Spit Groove: Online said direct trust, in fact, this means only to verify the user name, do not verify the password! Never use this!!!


METHOD specifies how the client's authentication is handled. Commonly used are ident,md5,password,trust,reject.

Ident is the default local authentication method under the Linux PostgreSQL, the user who can log on to the server correctly (note: not a database user) can use this user mapping database users do not need a password to log in to the database. The user mapping file is pg_ident.conf, which records database users that match the operating system user, and if an operating system user does not have a mapped user in this file, the default mapping database user has the same name as the operating system user. For example, the server is known as User1 operating system users, and the database also has the same name of the database user, User1 log on to the operating system can be directly entered Psql, to User1 database users to log into the database and do not require a password. Many beginners will encounter psql-u username login database But "Username ident authentication failed" error, clearly the database user has createuser. The reason for this is that the Ident authentication method is used, but there is no operating system user with the same name or no corresponding mapping user. Solution: 1, add the mapping user in pg_ident.conf, 2, change the authentication method.

MD5 is a common method of password authentication, if you do not use ident, it is best to use MD5. The password is transmitted to the database in the form of MD5, which is more secure and does not require an operating system user with the same name.

Password is sent to the database in plaintext and is not recommended for use in a production environment.

Trust does not require a password or ident to log in as long as the database username is known, and is not recommended for use in a production environment.

Reject is a denial of certification.

In the file lookup listen_addresses, his value description

If you want the PostgreSQL database to be accessible only from the local computer, set the entry to ' localhost ';
If you want to access the PostgreSQL database from the LAN, set the key to the LAN IP address of the PostgreSQL database;
If you want to access the PostgreSQL database from the Internet, set this to the Internet IP address of the PostgreSQL database;
If you want to access the PostgreSQL database from anywhere, set the configuration item to "*";


To create a user:


# Create database user dbuser first
Postgres=# create user dbuser with password ‘password’;
# Create system user
Adduser dbuser
# Modify system user password
Passwd dbuser


To modify the Dbuser password:


# Switch user to Postgresu postgres# Login psql# Modify dbuser password postgres=# alter user Dbuser with password ' own password ';
# or
postgres=# \password Dbuser


Assigning database permissions to Dbuser:


# Assign when creating a database
Postgres=# create database database name owner dbuser;
# Give the user postgres permission after creating the database
Postgres=# grant all privileges on database database name to dbuser;


Connect to the database as Dbuser:


Su dbuserpsql-d database name



Reference:



46047483



Http://www.ruanyifeng.com/blog/2013/12/getting_started_with_postgresql.html



PostgreSQL Remote Connection Configuration Management/account password Assignment (FIX: Fatal error: User "Postgres" Ident authentication failed)


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.