1、切换到ubuntu用户postgres
root@pc:~# su postgres #postgres是ubuntu的用户
postgres@pc:~#
2、创建数据库用户
postgres@pc:~# createuser -drSP root #用户名:root
Enter password for new role:
Enter it again:
3、查看数据库用户
postgres@pc:~# psql #输入psql,进入数据库
postgres=# \du #输入\du
Role name | Attributes | Member of
-----------+------------------------------------------------------------+-----------
postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
root | Create role, Create DB | {}
退出数据库:
postgres=# \q #输入\q