postgresql修改端口后使用psql连接数据库出现报错如何解决

发布时间:2021-01-11 16:28:14 作者:Leah
来源:亿速云 阅读:370

本篇文章给大家分享的是有关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=#

这样就可以直接进库了

补充: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 端口号

以上就是postgresql修改端口后使用psql连接数据库出现报错如何解决,小编相信有部分知识点可能是我们日常工作会见到或用到的。希望你能通过这篇文章学到更多知识。更多详情敬请关注亿速云行业资讯频道。

推荐阅读:
  1. 怎么解决rhel6.5系统重启后出现报错问题
  2. PostgreSQL 登陆工具pgAdmin以及psql使用

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

postgresql psql

上一篇:Object.assign()怎么在ES6 中使用

下一篇:File与FileStream怎么在C#中使用

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》