【发布时间】:2015-08-21 19:26:28
【问题描述】:
问题:我可以从 shell(bash、OSX)创建用户或数据库,但不能从 postgres cli 创建用户或数据库。如果成功,我不会从 bash 得到确认。
如果我尝试在 psql 中创建角色,那么我没有得到任何响应,也不会产生任何错误。如果我尝试 createuser 从 bash 则如果成功则不会报告任何内容,如果不成功则确实会生成错误:“角色用户名已存在”。
Example:
Yunti-# CREATE ROLE testuser
Yunti-# \du
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------+-----------
Yunti | Superuser, Create role, Create DB, Replication | {}
anything | | {}
monkey | | {}
Yunti-# CREATE DATABASE testdb
Yunti-# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+-------+----------+-------------+-------------+-------------------
Yunti | Yunti | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
postgres | Yunti | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | Yunti | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/Yunti +
| | | | | Yunti=CTc/Yunti
template1 | Yunti | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/Yunti +
| | | | | Yunti=CTc/Yunti
test | Yunti | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
test5 | Yunti | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
(6 rows)
Yunti-#
使用 createdb 时也会发生类似的情况。
如何在 postgres cli 中创建用户和数据库? 对 bash 中的大多数 postgres 命令没有响应是正常的吗?
信息:用户及其权限:
Yunti-# \du
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------+-----------
Yunti | Superuser, Create role, Create DB, Replication | {}
anything | | {}
monkey | | {}
【问题讨论】:
-
你是如何安装 PostgreSQL 的,从哪里安装的?
-
谢谢,就这么简单,需要 ; (必须少做python,多做sql/javascript;实践)
标签: postgresql psql