如何更改 postgresql 数据库连接的默认用户名?
How to change the default username a postgresql db is connecting to?
我看过描述如何设置 postgresql 服务器以连接到您自己的用户的帖子,但我找不到任何描述如何使 psql
连接到默认 postgres
用户的帖子默认情况下。在我的例子中,安装后,当我打开 psql
时,它连接到与我的 windows 用户同名的用户名,而不是我希望它连接到的 postgres
用户.
您可以使用以下数据创建一个 psqlrc.conf 文件:
\c <database> <user>
Doc 说:
The user's personal startup file is named .psqlrc and is sought in the
invoking user's home directory. On Windows, which lacks such a
concept, the personal startup file is named
%APPDATA%\postgresql\psqlrc.conf. The location of the user's startup
file can be set explicitly via the PSQLRC environment variable.
As documented in the manual 你可以定义一个环境变量 PGUSER
来代替你的 Windows 用户作为所有 Postgres 命令行工具的默认用户。
我看过描述如何设置 postgresql 服务器以连接到您自己的用户的帖子,但我找不到任何描述如何使 psql
连接到默认 postgres
用户的帖子默认情况下。在我的例子中,安装后,当我打开 psql
时,它连接到与我的 windows 用户同名的用户名,而不是我希望它连接到的 postgres
用户.
您可以使用以下数据创建一个 psqlrc.conf 文件:
\c <database> <user>
Doc 说:
The user's personal startup file is named .psqlrc and is sought in the invoking user's home directory. On Windows, which lacks such a concept, the personal startup file is named %APPDATA%\postgresql\psqlrc.conf. The location of the user's startup file can be set explicitly via the PSQLRC environment variable.
As documented in the manual 你可以定义一个环境变量 PGUSER
来代替你的 Windows 用户作为所有 Postgres 命令行工具的默认用户。