81
69

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.

PostgreSQLのインストールから起動/停止まで

Posted at

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
81
69
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
81
69

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?