我在Linux mint 18上安装了postres9。我以默认的postres用户登录。我尝试创建新用户并以该用户身份登录。
kalinin@lenovo ~ $ sudo -i -u postgres
postgres@lenovo ~ $ psql
psql (9.5.16)
Type "help" for help.
postgres=# CREATE DATABASE db_test;
CREATE DATABASE
postgres=# CREATE USER user_test WITH PASSWORD 'qwerty';
CREATE ROLE
postgres=#
postgres=#
postgres=# GRANT ALL PRIVILEGES ON DATABASE "db_test" to user_test;
GRANT
postgres=# \du
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------------------+-----------
postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
user_test | | {}
postgres=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-------------+----------+----------+-------------+-------------+------------------------
db_test | postgres | UTF8 | ru_RU.UTF-8 | ru_RU.UTF-8 | =Tc/postgres +
| | | | | postgres=CTc/postgres +
| | | | | user_test=CTc/postgres
postgres | postgres | UTF8 | ru_RU.UTF-8 | ru_RU.UTF-8 |
postgres=# \q
postgres@lenovo ~ $ exit
logout
kalinin@lenovo ~ $ sudo -i -u user_test
sudo: unknown user: user_test
sudo: unable to initialize policy plugin
您会看到我正在使用密码和新数据库创建新用户的情况。之后,我从postgres退出,然后再次尝试登录。但是登录失败。请帮助修复它。