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=#
我的偏好是使用数据库 shorturl 作为用户 shorturl 而不是 postgres。我该如何更改?
提前致谢。
最佳答案
当您通过输入\?
显示psql
联机帮助时,您可以看到:
Connection
\c[onnect] {[DBNAME|- USER|- HOST|- PORT|-] | conninfo}
connect to new database (currently "postgres")
所以你需要使用:
\c shorturl shorturl
关于postgresql - 你如何更改 PostgreSQL 中的用户?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44051059/