Rails connection PostgreSQL error: psql: Fatal error: User Login sident authentication failed
Rails connection PostgreSQL error: psql: Fatal error: User's ipvs Ident authentication failed
Psql: Fatal error: User "s" Ident authentication failed
1. After the postgresql database is installed, you must initialize and configure some rails projects to connect to postgresql.
After postgresql data is installed (the yum command is directly installed)
Step 1: Initialize the database
# Service postgresql initdb
(Note: After initialization, the default postgresql database has a default user named S (the password is blank) and a default created postgres database)
Step 2: Start the database
# Service postgresql start
If this command cannot be used, use: # systemctl start postgresql. service
To start the database.
Step 3: Change the user's password
# Su ipvs
# Psql
# Alter user Login s with password 'kuange ';
(Change the postgres user password to kuange. You can change this password as needed)
# \ Q
Step 4: Modify the authentication file/var/lib/pgsql/data/pg_hba.conf and log on to the system using the password.
# Vi/var/lib/pgsql/data/pg_assist.conf
You can change the ident of the authentication METHOD in this configuration file to trust to access the database using the account and password,
That is to solve the problem of psql: Fatal error: User "s" Ident authentication failure)
Step 5: restart the postgresql server to make the settings take effect.
# Service postgresql restart
Or
# Systemctl restart postgresql. service
The problem is solved, and the database can be normally accessed by the rails project.
The complete code for the pg_cmd.conf file is as follows:
#===================================================== =
# PostgreSQL Client Authentication Configuration File
#===================================================== ================
#
# Refer to the "Client Authentication" section in the PostgreSQL
# Documentation for a complete description of this file. A short
# Synopsis follows.
#
# This file controls: which hosts are allowed to connect, how clients
# Are authenticated, which PostgreSQL user names they can use, which
# Databases they can access. Records take one of these forms:
#
# Local database user method [OPTIONS]
# Host database user address method [OPTIONS]
# Hostssl database user address method [OPTIONS]
# Hostnossl database user address method [OPTIONS]
#
# (The uppercase items must be replaced by actual values .)
#
# The first field is the connection type: "local" is a Unix-domain
# Socket, "host" is either a plain or SSL-encrypted TCP/IP socket,
# "Hostssl" is an SSL-encrypted TCP/IP socket, and "hostnossl" is
# Plain TCP/IP socket.
#
# DATABASE can be "all", "sameuser", "samerole", "replication",
# Database name, or a comma-separated list thereof. The "all"
# Keyword does not match "replication". Access to replication
# Must be enabled in a separate record (see example below ).
#
# USER can be "all", a user name, a group name prefixed with "+", or
# Comma-separated list thereof. In both the DATABASE and USER fields
# You can also write a file name prefixed with "@" to include names
# From a separate file.
#
# ADDRESS specifies the set of hosts the record matches. It can be
# Host name, or it is made up of an IP address and a CIDR mask that is
# An integer (between 0 and 32 (IPv4) or 128 (IPv6) hybrid) that
# Specifies the number of significant bits in the mask. A host name
# That starts with a dot (.) matches a suffix of the actual host name.
# Alternatively, you can write an IP address and netmask in separate
# Columns to specify the set of hosts. Instead of a CIDR-address, you
# Can write "samehost" to match any of the server's own IP addresses,
# Or "samenet" to match any address in any subnet that the server is
# Directly connected.
#
# METHOD can be "trust", "reject", "md5", "password", "gss", "sspi ",
# "Krb5", "ident", "peer", "pam", "ldap", "radius" or "cert". Note that
# "Password" sends passwords in clear text; "md5" is preferred since
# It sends encrypted passwords.
#
# OPTIONS are a set of options for the authentication in the format
# NAME = VALUE. The available options depend on the different
# Authentication methods -- refer to the "Client Authentication"
# Section in the documentation for a list of which options are
# Available for which authentication methods.
#
# Database and user names containing spaces, commas, quotes and other
# Special characters must be quoted. Quoting one of the keywords
# "All", "sameuser", "samerole" or "replication" makes the name lose
# Its special character, and just match a database or username
# That name.
#
# This file is read on server startup and when the postmaster has es
# A SIGHUP signal. If you edit the file on a running system, you have
# To SIGHUP the postmaster for the changes to take effect. You can
# Use "pg_ctl reload" to do that.