MacにPostgreSQLをインストールする
PostgreSQL
Lastmod: 2023-10-09

はじめに

SQLの勉強のためにPostgreSQLを使いたいと思います。そこで自分のMacにPostgreSQLをインストールしていきたいと思います。

環境はこんな感じ。

  • macOS Catallina 10.15.6
  • Homebrew 2.5.2

手順

インストール

$ brew install postgresql

初期化

$ initdb /usr/local/var/postgres -E utf8

起動

$ brew services start postgresql

バージョン確認

$ psql -V
psql (PostgreSQL) 12.4

現在(2020/10/1)では12.4が最新みたいです。

データベースのリスト確認

こんな感じで確認できたらOK

$ psql -l
                         List of databases
   Name    | Owner | Encoding | Collate | Ctype | Access privileges 
-----------+-------+----------+---------+-------+-------------------
 postgres  | xxx   | UTF8     | C       | C     | 
 template0 | xxx   | UTF8     | C       | C     | =c/xxx          +
           |       |          |         |       | xxx=CTc/xxx
 template1 | xxx   | UTF8     | C       | C     | =c/xxx          +
           |       |          |         |       | xxx=CTc/xxx
(3 rows)

参考