LoginSignup
0
0

PostgreSQLのインストール

Posted at

1.Postgresqlのインストール

以下の記事を参考にさせていただききました。
【MacOSX】Postgresql 14.4のインストール

2.PATHの確認

1.postgreSQLの実行場所を探すため以下コマンドをターミナルで実行
$ locate psql | grep /bin

すると、

WARNING: The locate database (/var/db/locate.database) does not exist.
To create the database, run the following command:

  sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist

Please be aware that the database can take some time to generate; once
the database has been created, this message will no longer appear.

このようなメッセージが表示されます。
要約するとデーターベースを作成してくださいとのメッセージ。
エラーメッセージに書いてある以下コマンドをターミナルで実行

sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist

これでデータベースが作成されるので処理が終わったら、先程のコマンド実行

$ locate psql | grep /bin       
/Library/PostgreSQL/15/bin/psql
/Library/PostgreSQL/15/debug_symbols/bin/psql.dSYM
/Library/PostgreSQL/15/debug_symbols/bin/psql.dSYM/Contents
/Library/PostgreSQL/15/debug_symbols/bin/psql.dSYM/Contents/Info.plist
/Library/PostgreSQL/15/debug_symbols/bin/psql.dSYM/Contents/Resources
/Library/PostgreSQL/15/debug_symbols/bin/psql.dSYM/Contents/Resources/DWARF
/Library/PostgreSQL/15/debug_symbols/bin/psql.dSYM/Contents/Resources/DWARF/psql

これでPATHが確認できました。

3.vimでPATHを通す

vim ~/.zshrcコマンドでエデイターを起動
iで編集モードにして以下を追記

export PATH=$PATH:"/Library/PostgreSQL/15/bin"

最後にpsql --versionコマンドでバージョンを確認して以下のように表示されたら完了です

$ psql --version                
psql (PostgreSQL) 15.3

参考資料など
【MacOSX】Postgresql 14.4のインストール
Mac psqlコマンドのPATHを通す
MacにpostgreSQLをインストールしてpsqlコマンドを使用する方法
rails6でデータベースを変更した話

0
0
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
0
0