Postgres CLI 错误:尝试运行任何 psql 命令时数据库“dev”不存在

Rus*_*sty 2 postgresql macos psql apple-m1

我使用自制程序安装 postgres 版本 14。

brew install postgresql 
Run Code Online (Sandbox Code Playgroud)

每当我尝试运行 psql 命令时,都会收到以下错误:

psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: 
FATAL: database "dev" does not exist
Run Code Online (Sandbox Code Playgroud)

以下是我的系统路径

/Users/dev/.nvm/versions/node/v15.14.0/bin:
/opt/homebrew/bin:
/opt/homebrew/sbin:
/usr/local/bin:
/usr/bin:
/bin:
/usr/sbin:
/sbin:
/usr/local/MacGPG2/bin:
/Library/Apple/usr/bin:
Run Code Online (Sandbox Code Playgroud)

Vyn*_*kie 5

您必须在连接字符串中使用“dev”名称?你能告诉我们吗?postgres 中的默认数据库称为 postgres,没有 dev 数据库。

当连接到新安装的 Postgres 时,进入psql命令行实际上会执行类似的操作

psql -d postgres -U postgres -p 5432 -h localhost
Run Code Online (Sandbox Code Playgroud)

这些是默认值,所以psql没问题。

您/您的应用程序正在输入类似以下内容:

psql -d dev -U [user] -p [port] -h [host]
Run Code Online (Sandbox Code Playgroud)