---
title: "用 homebrew 升级 postgres 数据库"
description: "要升级 postgres，可以运行"
canonical: https://oozou.com/til/upgrade-postgres-database-with-homebrew-76
locale: zh-Hans
date: 2020-10-22
topic: shell
---

# 用 homebrew 升级 postgres 数据库

> 要升级 postgres，可以运行

Published: 2020-10-22 · Topic: [shell](https://oozou.com/zh-Hans/til-topics/shell) ([markdown](https://oozou.com/zh-Hans/til-topics/shell.md))

要升级 postgres，可以运行

```shell
brew upgrade postgresql
```

升级完成之后，你现有数据库里的数据会和新的 postgres 可执行文件不兼容。通常你得使用 pg\_update 并传入正确的可执行文件来迁移数据，不过 brew 内置了一个升级脚本，可以帮你更新数据。

```shell
brew postgresql-upgrade-database
```

---

Contact OOZOU: hello@oozou.com · +66 2544 0000 · https://oozou.com/zh-Hans/contact

More for AI agents: https://oozou.com/llms.txt · every page has a markdown twin at its URL plus ".md"
