你如何更改 PostgreSQL 中的用户?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/44051059/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 02:34:32 来源:igfitidea点击:
How do you change a user in PostgreSQL?
提问by Abhinav Ralhan
postgres=# \du
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------+-----------
postgres | Superuser, Create role, Create DB, Replication | {}
shorturl | Superuser | {}
postgres=# create database shorturl;
CREATE DATABASE
postgres=# \c shorturl;
You are now connected to database "shorturl" as user "postgres".
shorturl=#
My preference was to use database shorturlbeing the user shorturland not postgres. How do I change the same?
我的偏好是使用数据库shorturl作为用户shorturl而不是postgres。我如何更改相同?
Thanks in advance.
提前致谢。
回答by a_horse_with_no_name
When you display the psql
online help by entering \?
you can see:
当您psql
通过输入显示在线帮助时,\?
您可以看到:
Connection
\c[onnect] {[DBNAME|- USER|- HOST|- PORT|-] | conninfo}
connect to new database (currently "postgres")
So you need to use:
所以你需要使用:
\c shorturl shorturl