1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Homebrewを用いてPostgreSQL 12をインストールする方法

Posted at

概要

2019年12月10日時点での情報になります。

2019年10月3日にPostgreSQL 12がリリースされました1
本記事では、PostgreSQL 12をHomebrewでインストールする方法を説明します。

方法1(新規にインストールする場合)


brew install postgresql

brew installしただけではパスが通っていないので~/.bashrcに以下の記述を追加します。

export PATH=/usr/local/Cellar/postgresql/12.1/bin/:$PATH

方法2(すでにpostgresqlをインストールしていてかつ既存のバージョンがいらない場合)

注意点としては、upgradeをすると、既存のバージョンのpostgresqlは削除されてしまいます。
インストールディレクトリが変わるのでパスも変えましょう。


brew upgrade postgresql

方法3(複数バージョンのPostgreSQLを共存させたい場合)

方法2を実施した上で必要なバージョンのpostgresqlをインストールします。
brew search postgresqlを実行するとhomebrewでインストール可能な一覧を表示することができます。

brew search postgresql
brew install postgresql@11

方法4(サードパーティーからインストールする)

petere/postgresqlからもpostgresqlをインストールすることができます。

複数のメジャーバージョンの共存させたい場合はこちらからインストール方がいいと思います。
あとこっちの方が公式より最新のバージョンの反映が早いです。

例) 12.1のリリース対応
12.1は11月14日にリリースされています2。petere/postgresqlはすぐ対応されているのに対してhomebrew公式だと少しラグがあります。

brew tap petere/postgresql
brew search postgresql
brew install petere/postgresql/postgresql@12

brew tapコマンドを実行することで指定したサードパーティからもhomeberwでインストールすることができるようになります。

  1. https://www.postgresql.org/about/news/1976/

  2. https://www.postgresql.org/about/news/1994/

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?