问题描述
我在mt Windows 7机器上运行PostgreSQL。要运行数据库,我键入:
I'm running PostgreSQL on mt Windows 7 machine. To run a database I type:
C:\psql -Upostgres mydb
这可行,但如果我可以省掉 -U
但Postgres认为我试图以Eric身份登录,因为这是我的用户配置文件。
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.
所以我需要添加一个用户到Postgres。但是怎么样?如果我尝试:
So I need to add a user to Postgres, obviously. But how? If I try:
C:\createuser Eric
Postgres认为我试图添加一个用户Eric 作为用户Eric ,但失败。添加 -U
标志似乎在这里不起作用。
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.
我缺少什么?我的命令窗口处于管理员模式,并且没有 sudo
可用。
What am I missing? My command window is in administrator mode, and there is no sudo
available, obviously.
推荐答案
在pgadmin中,您可以创建一个新的登录角色,并将其命名为Eric并以图形方式向其授予权限,或者从命令行执行此操作。
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
请参阅了解有关CREATE ROLE选项的信息。
see http://developer.postgresql.org/pgdocs/postgres/sql-createrole.html for information on the CREATE ROLE options.
这篇关于如何在Windows中添加用户到PostgreSQL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!