Today, after modifying the port number of pg, it is changed to 5435, and after restarting the database, it is impossible to enter the database directly when psql enters the database.
[postgres@node2 data]$ psql psql: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/tmp/..5432
At this time, there are two ways to enter the database
1. Add the port number after psql
[postgres@node2 data]$ psql -p 5435 psql (9.6.1) Type "help" for help. postgres=#
2. Add a sentence to the environment variable /home/postgres/.bash_profile
export PGPORT=5435
Then
[postgres@node2 ~]$ source ~/.bash_profile [postgres@node2 ~]$ psql psql (9.6.1) Type "help" for help. postgres=#
This way you can enter the library directly
Supplement: How to connect to postgresql when psql is not the default port
How to connect to postgresql when psql is not the default port
[stork@instance-609xznso pgsql]$ /usr/pgsql-11/bin/psql c3_data -p 5432 could not change directory to “/var/lib/pgsql”: Permission denied Password for user stork: psql (11.5) Type “help” for help. c3_data=>
Just specify the port yourself
/usr/pgsql-11/bin/psql xxdatabase -p Port number
The above is personal experience. I hope you can give you a reference and I hope you can support me more. If there are any mistakes or no complete considerations, I would like to give you advice.