---
title: "mac homebrew postgresql 服务异常中断"
author: "friping"
date: "2016-04-07T10:50:20Z"
tags: []
categories: ["Web前端"]
slug: "mac-homebrew-postgresql"
draft: false
lastmod: "2017-02-23T09:58:02Z"
id: 2289052
url: "https://friping.iteye.com/blog/2289052"
---

1\. 断开连接

```
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
```

 

```
// 9.6 
brew services stop postgresql
```

 

 

 

2\. 删除/usr/local/var/postgres中的postmaster.pid

```
rm /usr/local/var/postgres/postmaster.pid
```

 

 

3\. 查看是否删除postmaster.pid

```
ls /usr/local/var/postgres
```

 

 

```
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
```

    /usr/local/Cellar/postgresql/9.4.4/homebrew.mxcl.postgresql.plist: Could not find specified service

   

```
// 9.6
brew services start postgresql
```

 

 

 

4\. 重新启动

```
 launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
```

 

```
// 9.6 
brew services start postgresql
```

 

 

 

一键复制

```
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
rm /usr/local/var/postgres/postmaster.pid
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
  
```

 

```
// 9.6  
brew services stop postgresql
rm /usr/local/var/postgres/postmaster.pid
brew services start postgresql 
```