Help us understand the problem. What is going on with this article?

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

More than 1 year has passed since last update.

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
sf213471118
プログラミング始めたばかりです。 某女子大に通っています。 授業でやったことなどをメモ代わりに書いていこうと思っています。 なにか間違いがあれば教えてくださると嬉しいですm(_ _)m
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした