如何在 Windows 中将用户添加到 PostgreSQL? [英] How to add a user to PostgreSQL in Windows?
问题描述
我在 mt Windows 7 机器上运行 PostgreSQL.要运行数据库,我输入:
C:psql -Upostgres mydb
这行得通,但如果我能去掉 -U
的东西就好了,但是 Postgres 认为我正在尝试以Eric"的身份登录,因为那是我的用户个人资料.
显然,我需要向 Postgres 添加一个用户.但是如何?如果我尝试:
C:createuser 埃里克
Postgres 认为我正在尝试添加用户 Eric 作为用户 Eric 但失败了.添加 -U
标志在这里似乎不起作用.
我错过了什么?我的命令窗口处于管理员模式,显然没有 sudo
可用.
在 pgadmin 中,您可以创建一个新的登录角色"并将其命名为 Eric 并以图形方式为其授予权限,或者您可以从命令行执行类似操作
>
psql -U postgres -c "CREATE ROLE Eric LOGIN NOSUPERUSER INHERIT CREATEDB CREATEROLE;"数据库
见http://developer.postgresql.org/pgdocs/postgres/sql-createrole.html 有关 CREATE ROLE 选项的信息.
I'm running PostgreSQL on mt Windows 7 machine. To run a database I type:
C:psql -Upostgres mydb
and this works, but it would be nice if I could leave off the -U
stuff, but then Postgres thinks I'm trying to log in as 'Eric', since that is my user profile.
So I need to add a user to Postgres, obviously. But how? If I try:
C:createuser Eric
Postgres thinks I'm trying to add a user Eric as the user Eric which fails. Adding the -U
flag doesn't seem to work here.
What am I missing? My command window is in administrator mode, and there is no sudo
available, obviously.
In pgadmin you can create a new "Login Role" and name it Eric and give it permissions graphically, or from command line you can do something like this
psql -U postgres -c "CREATE ROLE Eric LOGIN NOSUPERUSER INHERIT CREATEDB CREATEROLE;" mydb
see http://developer.postgresql.org/pgdocs/postgres/sql-createrole.html for information on the CREATE ROLE options.
这篇关于如何在 Windows 中将用户添加到 PostgreSQL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!