PostgreSQLについて忘れないようささっと。
今回の環境は
- macOS Mojave 10.14.5
- postgresql-11.4
##HomebrewでpostgreSQLインストール
terminal
$ brew install postgresql
~~
==> Summary
🍺 /usr/local/Cellar/postgresql/11.4: 3,188 files, 35.4MB
~~
数分で完了。
しっかり入ったことを確認
terminal
$ postgres --version /* psql -V でもOK */
postgres (PostgreSQL) 11.4
DBをUTF-8で初期化して
terminal
$ initdb /usr/local/var/postgres -E utf8
The files belonging to this database system will be owned by user "sf213471118".
This user must also own the server process.
The database cluster will be initialized with locale "ja_JP.UTF-8".
initdb: could not find suitable text search configuration for locale "ja_JP.UTF-8"
The default text search configuration will be set to "simple".
Data page checksums are disabled.
initdb: directory "/usr/local/var/postgres" exists but is not empty
If you want to create a new database system, either remove or empty
the directory "/usr/local/var/postgres" or run initdb
with an argument other than "/usr/local/var/postgres".
準備完了。
##postgreSQLの起動/停止
MacであればHomebrewのbrew services
コマンドを使うと便利。
MySQLであれば下記のpostgreSQLの部分だけ書き換えるだけでOK
###postgreSQLの起動
terminal
$ brew services start postgresql
==> Successfully started `postgresql` (label: homebrew.mxcl.postgresql)
起動完了。
###postgreSQLの停止
terminal
$ brew services stop postgresql
Stopping `postgresql`... (might take a while)
==> Successfully stopped `postgresql` (label: homebrew.mxcl.postgresql)
停止完了。
###postgreSQLの起動状況の確認
これが起動状態
terminal
$ brew services list
Name Status User Plist
postgresql started sf213471118 /Users/sf213471118/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
これが停止状態
terminal
$ brew services list
Name Status User Plist
postgresql stopped