unbeknowndict

i have an unbeknown dictionary. everything is up to me.

MojaveにhomebrewでPostgreSQLをinstall

environment

  • mac OS Mojave 10.14.2
  • psql (PostgreSQL) 11.1
  • pg_ctl (PostgreSQL) 11.1

install

brew doctor
brew update
brew install postgresql

...{ellipsis}...

To migrate existing data from a previous major version of PostgreSQL run:
  brew postgresql-upgrade-database

To have launchd start postgresql now and restart at login:
  brew services start postgresql
Or, if you don't want/need a background service you can just run:
  pg_ctl -D /usr/local/var/postgres start
==> Summary
🍺  /usr/local/Cellar/postgresql/11.1_1: 3,548 files, 40.3MB

postgresql.conf のlistenはlocalのみ可能にする。

#listen_addresses = 'localhost'    # what IP address(es) to listen on;
listen_addresses = 'localhost'

brew services start postgresql を試して起動していそうに思えるも、プロセスおらず。

brew services start postgresql
==> Successfully started `postgresql` (label: homebrew.mxcl.postgresql)

pg_ctl -D /usr/local/var/postgres start を試すも、database fileが不完全でinitial時のPostgreSQL version差異があるとのエラーが出る。

pg_ctl -D /usr/local/var/postgres start
waiting for server to start....2019-02-22 22:54:14.872 JST [4307] FATAL:  database files are incompatible with server
2019-02-22 22:54:14.872 JST [4307] DETAIL:  The data directory was initialized by PostgreSQL version 10, which is not compatible with this version 11.1.
 stopped waiting
pg_ctl: could not start server
Examine the log output.

古いdatabaseファイルを消して initdb を行う。

rm -rf /usr/local/var/postgres && initdb /usr/local/var/postgres -E utf8
The files belonging to this database system will be owned by user "xxx".
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.

creating directory /usr/local/var/postgres ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... 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:

    pg_ctl -D /usr/local/var/postgres -l logfile start

起動

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

worker process forkされて正常に動いている。 接続もOK。

ps aux | grep postgres

psql -d postgres
psql (11.1)
Type "help" for help.