小编典典

从命令行创建数据库

all

我正在尝试从命令行创建数据库。我的操作系统是 centos,postgres 版本是 10.9。

sudo -u postgres psql createdb test
Password for user test:

为什么提示我输入密码?


阅读 123

收藏
2022-09-02

共1个答案

小编典典

将用户更改为 postgres :

su - postgres

为 Postgres 创建用户(在 shell 中,而 不是 使用 psql)

$ createuser testuser

创建数据库(相同)

$ createdb testdb

访问 postgres Shell

psql ( enter the password for postgressql)

为 postgres 用户提供权限

$ alter user testuser with encrypted password 'qwerty';
$ grant all privileges on database testdb to testuser;
2022-09-02