今天修改pg的端口号port改成5435后重启完数据库的时候直接psql进库的时候进不去
1 2 3 4 |
[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 后面加上端口号
1 2 3 4 |
[postgres@node2 data]$ psql -p 5435 psql (9.6.1) Type "help" for help. postgres=# |
2、在环境变量/home/postgres/.bash_profile中加上一句
1 |
export PGPORT=5435 |
然后
1 2 3 4 5 |
[postgres@node2 ~]$ source ~/.bash_profile [postgres@node2 ~]$ psql psql (9.6.1) Type "help" for help. postgres=# |
这样就可以直接进库了
补充:psql不是默认端口时如何连接 postgresql
psql不是默认端口时如何连接postgresql
1 2 3 4 5 6 |
[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=> |
自己指定端口就可以了
1 |
/usr/pgsql-11/bin/psql xxdatabase -p 端口号 |
以上为个人经验,希望能给大家一个参考,也希望大家多多支持服务器之家。如有错误或未考虑完全的地方,望不吝赐教。
原文链接:https://blog.csdn.net/silenceray/article/details/68066514
查看更多关于postgresql修改完端口后直接psql连接数据库报错的解决的详细内容...