0

我在 macos(big sur 11.4) 上安装了 postgres.app 2.4.2。

我想用 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

默认情况下没有postgrestemplate1数据库是有线的。

我尝试使用登录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"

我很困惑,我该如何解决这个问题或者我应该切换到自制版本?

4

0 回答 0