ITPub博客

首页 > IT职业 > IT职场 > 怎么启动postgresql服务器

怎么启动postgresql服务器

IT职场 作者:flytinge 时间:2021-09-11 10:24:46 0 删除 编辑

当postgres服务器没有启动时,psql命令会报错:

psql:无法连接到服务器: 没有那个文件或目录
    服务器是否在本地运行并且在 Unix 域套接字
    "/var/run/postgresql/.s.PGSQL.5432"上准备接受联接?

解决办法:

通过命令

/etc/init.d/postgresql start

启动postgres服务器。

收到信息

[ ok ] Starting postgresql (via systemctl): postgresql.service.

表示成功启动。

然后通过

sudo su - postgres

切换到用户postgres。

postgres用户下使用psql命令可进入数据库操作。

另:

停止postgres服务器:

/etc/init.d/postgresql stop

重启postgres服务器:

/etc/init.d/postgresql restart

 Python学习网,大量的免费PostgreSQL入门教程,欢迎在线学习!

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/3914/viewspace-2835053/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2026-01-07

  • 博文量
    0
  • 访问量
    2710