gpt4 book ai didi

postgresql - Postgres。角色 "root"不存在。尝试 pg :pull database from Heroku 时

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

我是 Postgres 和 Heroku 的新手。我正在尝试从 Heroku 中提取数据库,但我遗漏了一些简单的东西。我做了:

heroku pg:pull HEROKU_POSTGRESQL_IVORY_URL localdb

我得到了错误:

createdb: database creation failed: ERROR:  permission denied to create database

然后我用“sudo”做了同样的尝试。我得到了:

createdb: could not connect to database template1: FATAL:  role "root" does not exist

所以,一定是我遗漏了一些我找不到的简单命令。我在 Linux 上,我安装了 Postgres 并且可以正常工作。

最佳答案

createdb 是 SQL 语句 CREATE DATABASE 的包装器,因此它需要连接到数据库。

默认情况下,所有 Postgres 命令行工具都尝试使用当前操作系统用户连接到数据库。由于错误消息表明数据库中没有名为 root 的用户。因此,您需要传递 Postgres super 用户的名称,以便 createdb 能够连接。这个用户通常被命名为 postgres

如果存在这样的 Linux 用户,另一个选项是将 Linux 用户切换到 postgres

我不了解 Heroku,也不知道你是如何启动 createdb 的,但是传递用户名的参数是 -U(对于所有 Postgres 命令行程式)。所以你需要

 createdb -U postgres name_of_new_database

关于postgresql - Postgres。角色 "root"不存在。尝试 pg :pull database from Heroku 时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25049504/

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