initdb в Postgres.app не создает базу данных postgres и template1
Я установил postgres.app 2.4.2 на macos(big sur 11.4).
Я хотел initdb с
locale=C
, так что запустите команду
initdb -D "/Users/xxx/Library/Application Support/Postgres/var-131" -U postgres --encoding=UTF-8 --locale=C --auth-local=trust
и ведение журнала
(base) > $ initdb -D "/Users/xxx/Library/Application Support/Postgres/var-13_1" -U postgres --encoding=UTF-8 --locale=C --auth-local=trust
The files belonging to this database system will be owned by user "yy".
This user must also own the server process.
The database cluster will be initialized with locale "C".
The default text search configuration will be set to "english".
Data page checksums are disabled.
creating directory /Users/xxx/Library/Application Support/Postgres/var-13_1 ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... Asia/Hongkong
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok
initdb: 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 '/Users/xxx/Library/Application Support/Postgres/var-13_1' -l logfile start
В документе PG (https://www.postgresql.org/docs/13/app-initdb.html) сказано:
generating the shared catalog tables (tables that belong to
the whole cluster rather than to any particular database),
and creating the template1 and postgres databases
Было зашито, что не было
postgres
а также
template1
база данных по умолчанию.
Я пытался войти, используя
psql
и он отображал
role "username" does not exist
.
Я тоже пробовал
createuser -U postgres -s $USER
и он показал ошибку
(base) > $ createuser -U postgres -s $USER
createuser: error: could not connect to database template1: FATAL: Peer authentication failed for user "postgres"
Я был очень сбит с толку, а как мне решить вопрос или мне перейти на доморощенную версию?