1
2

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.

MacOSXでpostgresSQLのインストール→起動→ログイン→停止

Posted at

環境

OS: Mac.OS 10.10
brew: 0.9.5
psql (PostgreSQL): 9.4.1

ローカル環境でたまにPostgreSQLを使う機会があるが、
そのたびにググって時間とられるのでシンプルに備忘録

インストール

brew install postgresql

出力をみるとインストールと一緒に起動まで行われている

==> Downloading https://homebrew.bintray.com/bottles/postgresql-9.4.1.yosemite.bottle.1.tar.gz
Already downloaded: /Library/Caches/Homebrew/postgresql-9.4.1.yosemite.bottle.1.tar.gz
==> Pouring postgresql-9.4.1.yosemite.bottle.1.tar.gz
==> Caveats
If builds of PostgreSQL 9 are failing and you have version 8.x installed,
you may need to remove the previous version first. See:
  https://github.com/Homebrew/homebrew/issues/2510

To migrate existing data from a previous major version (pre-9.4) of PostgreSQL, see:
  http://www.postgresql.org/docs/9.4/static/upgrading.html

To have launchd start postgresql at login:
    ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
Then to load postgresql now:
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
Or, if you don't want/need launchctl, you can just run:
    postgres -D /usr/local/var/postgres
==> Summary
🍺  /usr/local/Cellar/postgresql/9.4.1: 2996 files, 40M


※ バージョンによってはできるらしいが、自分のバージョンだとどうやらbrewでインストールすると自分で起動・停止ができないらしい

起動

postgres -D /usr/local/var/postgres

停止

pg_ctl -D /usr/local/var/postgres stop

コンソールログイン

psql 

コンソール終了

\q

参考:

psqlの使いかた
http://ash.jp/db/pg_psql.htm

1
2
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
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?