Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Postgresql 从psql创建数据库:对等身份验证失败_Postgresql - Fatal编程技术网

Postgresql 从psql创建数据库:对等身份验证失败

Postgresql 从psql创建数据库:对等身份验证失败,postgresql,Postgresql,我已经在Ubuntu上安装了Postgresql postgres=# \du List of roles Role name | Attributes | Member of -----------+------------------------------------------------------------+--

我已经在Ubuntu上安装了Postgresql

postgres=# \du 
                                   List of roles
 Role name |                         Attributes                         | Member of 
-----------+------------------------------------------------------------+-----------
 mark      | Superuser, Create role, Create DB                          | {}
 jh        |                                                            | {}
 postgres  | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
当我尝试

sudo -u postgres psql createdb rates
psql: FATAL:  Peer authentication failed for user "rates"

我想为角色名称标记创建rates db。如何执行此操作?

createdb
不是SQL命令,因此您不从数据库客户端执行,而是从shell执行

试一试

sudo -u postgres psql -c 'CREATE DATABASE rates'
sudo -u postgres createdb rates