gpt4 book ai didi

postgresql - 从命令行创建数据库

转载 作者:行者123 更新时间:2023-11-29 11:05:33 25 4
gpt4 key购买 nike

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

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

为什么提示我输入密码?

最佳答案

将用户更改为 postgres :

su - postgres

为 Postgres 创建用户(在 shell 中并且 NOT 使用 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;

关于postgresql - 从命令行创建数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30641512/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com