🐘
postgreSQLの新バージョンインストール
はじめに
随分前に個人のmacbookにpostgreSQLをインストールしたままほったらかしになってました。新しくローカルアプリを開発するのにpostgreSQL最新版にしておこうと思ったので、その作業記録を残しておきます。
1. 現在使用中のpostgresqlバージョン確認
psql -Vコマンドでバージョン確認を行います。
% psql -V
psql (PostgreSQL) 14.13 (Homebrew)
現在のバージョンはhomebrewでインストールしたpostgresql@14.13となってます。
2. homebrewで新バージョンのインストール
brewコマンドでpostgreSQL17をインストール。(現時点の最新版は17.5)
% brew install postgresql@17
==> Downloading https://ghcr.io/v2/homebrew/core/postgresql/17/manifests/17.5
############################################################################################################################################################# 100.0%
==> Fetching postgresql@17
==> Downloading
...省略...
==> Running `brew cleanup postgresql@17`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
インストールが完了したようです。
3. バージョンの一覧を確認
新バージョンがインストールされたか確認する。
% brew list | grep postgresql
postgresql@14
postgresql@17
@17もリストにありました。
4.バージョンの切り替え
インストールしただけでは使えないので、有効化(リンク)してあげる必要があります。
まずbrew unlinkコマンドで現在のバージョンを無効化します。
% brew unlink postgresql@14
Unlinking /opt/homebrew/Cellar/postgresql@14/14.13... 2162 symlinks removed.
その後、brew linkコマンドで新バージョンを有効にします。
% brew link postgresql@17 --force
Linking /opt/homebrew/Cellar/postgresql@17/17.5... 802 symlinks created.
If you need to have this software first in your PATH instead consider running:
echo 'export PATH="/opt/homebrew/opt/postgresql@17/bin:$PATH"' >> ~/.zshrc
さいごに
現在のバージョンを確認
% psql -V
psql (PostgreSQL) 17.5 (Homebrew)
無事切り替わった事が確認できました!
これで私のmacbookのpostgreSQLのデフォルトバージョンは17.5になりました。
Discussion