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的 即可。我该如何改变呢?
提前致谢。
答案 0 :(得分:15)
当您输入psql
显示\?
在线帮助时,您可以看到:
Connection
\c[onnect] {[DBNAME|- USER|- HOST|- PORT|-] | conninfo}
connect to new database (currently "postgres")
所以你需要使用:
\c shorturl shorturl