postgresql修改完埠後直接psql連線資料庫報錯的解決
阿新 • • 發佈:2021-01-12
今天修改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=#
這樣就可以直接進庫了
補充:psql不是預設埠時如何連線postgresql
psql不是預設埠時如何連線postgresql
[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=>
自己指定埠就可以了
/usr/pgsql-11/bin/psql xxdatabase -p 埠號
以上為個人經驗,希望能給大家一個參考,也希望大家多多支援我們。如有錯誤或未考慮完全的地方,望不吝賜教。