首页 > 技术文章 > postgresql服务器的启动

RDaneelOlivaw 2018-01-01 09:44 原文

当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

 

推荐阅读