Centos7shell postgres login failed

clipboard.png
Baidu said that there is a problem with the verification method in the file / var/lib/pgsql/9.5/data/pg_hba.conf, but the reason for changing the verification method is to use the command psql-U postgres-d mydjango-p 5432-h 127.0.0.1
to log in directly in shell. What is the reason

?

sudo -u postgres psql

finish work


after modifying the configuration file

clipboard.png

it should be the restart command that cannot use service postgresql restart
service postgresql reload
service postgresql reload to https://jingyan.baidu.com/art.
seems to be postgres.conf using restart pg_hba using reload

I did this using the following method. After modifying the configuration file at the same time, I used the service postgresql reload command to restart, and finally used the second method of successful login
, using the shell command line.

adding new users and databases can be done not only in the PostgreSQL console, but also on the shell command line. This is because PostgreSQL provides command-line programs createuser and createdb. Take the new user dbuser and database exampledb as an example.

first, create the database user dbuser, and specify it as a superuser.

sudo-u postgres createuser-- superuser dbuser

then, log in to the database console, set the password for the dbuser user, and exit the console when you are finished.

sudo-u postgres psql

password dbuser

Q

then, under the shell command line, create the database exampledb, and specify the owner as dbuser.

sudo-u postgres createdb-O dbuser exampledb

Log in to the database

after you add a new user and a new database, log in to the database as the new user, using the psql command.

psql-U dbuser-d exampledb-h 127.0.0.1-p 5432

the parameters of the above command are as follows:-U specifies the user,-d specifies the database,-h specifies the server, and-p specifies the port.

after entering the above command, you will be prompted for the password of the dbuser user. If you enter it correctly, you can log in to the console.

Menu