您的位置:首页 > 博客中心 > 数据库 >

在Postgresql中添加新角色(Role)

时间:2022-03-14 04:16

Postgresql安装完成之后,默认会创建名为postgres的用户、角色(Role)和数据库(Database)。而使用你自己原有的用户运行psql时会提示错误。

bob@localhost:~$ psql
psql: FATAL: role "bob" does not exist

如果想要使用自己的用户"bob"来运行psql,就需要在Postgresql中添加名为"bob"的角色(Role)。

bob@localhost:~$ sudo -u postgres -i
[sudo] password for bob:
postgres@localhost:~$ psql -c "CREATE ROLE bob SUPERUSER LOGIN"
postgres@localhost:~$ psql -c "CREATE DATABASE bob"

之后使用exit命令退出postgres返回bob,再次运行psql即可。

 

热门排行

今日推荐

热门手游