読者です 読者をやめる 読者になる 読者になる

牌語備忘録 -pygo

あくまでもメモです。なるべくオフィシャルの情報を参照してください。

牌語備忘録 -pygo

PostgreSQL を MacPorts でインストールするメモ

MacOSX PostgreSQL

(macos 10.9)

PostgreSQL 9.3 をインストール。 そのうち homebrew に乗り替えたいと思いつつ今だに MacPorts

インストール

$ sudo port install postgresql93
$ sudo port install postgresql93-server
 :
To create a database instance, after install do
 sudo mkdir -p /opt/local/var/db/postgresql93/defaultdb
 sudo chown postgres:postgres /opt/local/var/db/postgresql93/defaultdb
 sudo su postgres -c '/opt/local/lib/postgresql93/bin/initdb -D /opt/local/var/db/postgresql93/defaultdb'

$ sudo su postgres -c '/opt/local/lib/postgresql93/bin/initdb -D /opt/local/var/db/postgresql93/defaultdb'
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /opt/local/var/db/postgresql93/defaultdb ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
creating configuration files ... ok
creating template1 database in /opt/local/var/db/postgresql93/defaultdb/base/1 ... ok
initializing pg_authid ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects' descriptions ... ok
creating collations ... ok
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
loading PL/pgSQL server-side language ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok
syncing data to disk ... ok

WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    /opt/local/lib/postgresql93/bin/postgres -D /opt/local/var/db/postgresql93/defaultdb
or
    /opt/local/lib/postgresql93/bin/pg_ctl -D /opt/local/var/db/postgresql93/defaultdb -l logfile start

port select する

これしないと psql が使えない

$ port select --list postgresql
Available versions for postgresql:
    none (active)
    postgresql93
$ sudo port select --set postgresql postgresql93
$ which psql
/opt/local/bin/psql

起動

$ sudo su postgres -c '/opt/local/lib/postgresql93/bin/postgres -D /opt/local/var/db/postgresql93/defaultdb'
$ psql -U postgres
psql (9.3.6)
Type "help" for help.

postgres=#

自動起動する場合

$ sudo launchctl load -w /Library/LaunchDaemons/org.macports.postgresql93-server.plist
$ sudo launchctl start org.macports.postgresql93-server

サーバ停止

$ sudo launchctl stop org.macports.postgresql93-server

自動起動を停止

$ sudo launchctl unload -w /Library/LaunchDaemons/org.macports.postgresql93-server.plist

参考