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即可。

 

相关文章:

  • 2022-12-23
  • 2021-07-24
  • 2021-09-20
  • 2022-12-23
  • 2021-09-09
  • 2021-06-24
  • 2021-12-10
  • 2021-07-07
猜你喜欢
  • 2022-12-23
  • 2022-01-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-25
相关资源
相似解决方案