postgresql修改完端口后直接psql连接数据库报错

今天修改pg的端口号port改成5435后重启完数据库的时候直接psql进库的时候进不去
[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/.s.PGSQL.5432

这时,进数据库有两种方式
1、psql 后面加上端口号
[postgres@node2 data]$ psql -p 5435
psql (9.6.1)
Type "help" for help.

postgres=#
2、在环境变量/home/postgres/.bash_profile中加上一句
export PGPORT=5435
然后
[postgres@node2 ~]$ source ~/.bash_profile
[postgres@node2 ~]$ psql
psql (9.6.1)
Type "help" for help.

postgres=#
这样就可以直接进库了
————————————————
版权声明:本文为CSDN博主「奈何流年」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/silenceray/java/article/details/68066514

原文地址:https://www.cnblogs.com/telwanggs/p/12664778.html