今天修改pg的端口號(hào)port改成5435后重啟完數(shù)據(jù)庫(kù)的時(shí)候直接psql進(jìn)庫(kù)的時(shí)候進(jìn)不去
[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
這時(shí),進(jìn)數(shù)據(jù)庫(kù)有兩種方式
1、psql 后面加上端口號(hào)
[postgres@node2 data]$ psql -p 5435
psql (9.6.1)
Type "help" for help.
postgres=#
2、在環(huán)境變量/home/postgres/.bash_profile中加上一句
然后
[postgres@node2 ~]$ source ~/.bash_profile
[postgres@node2 ~]$ psql
psql (9.6.1)
Type "help" for help.
postgres=#
這樣就可以直接進(jìn)庫(kù)了
補(bǔ)充:psql不是默認(rèn)端口時(shí)如何連接postgresql
psql不是默認(rèn)端口時(shí)如何連接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 端口號(hào)
以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教。
您可能感興趣的文章:- 解決postgreSql遠(yuǎn)程連接數(shù)據(jù)庫(kù)超時(shí)的問(wèn)題
- postgres 連接數(shù)查看與設(shè)置操作