简体   繁体   English

使用 pgadmin 连接到 heroku 数据库

[英]Connect to a heroku database with pgadmin

I would like to manage my heroku database with pgadmin client.我想用pgadmin客户端管理我的 heroku 数据库。 By now, I've been doing this with psql .到现在psql ,我一直在用psql做这件事。 When I use data from heroku pg:credentials to connect de DB using pgadmin , I obtain:当我使用来自heroku pg:credentials数据使用pgadmin连接 de DB 时,我获得:

An error has occurred:发生了错误:

Error connecting to the server: FATAL: permission denied for database "postgres" DETAIL: User does not have CONNECT privilege.连接到服务器时出错:致命:数据库“postgres”的权限被拒绝详细信息:用户没有连接权限。

Any guide on how to achieve the connection?有关如何实现连接的任何指南?

Open the "Properties" of the Heroku server in pgAdminIII and change the "Maintenance DB" value to be the name of the database you want to connect to.在 pgAdminIII 中打开 Heroku 服务器的“属性”并将“维护数据库”值更改为要连接的数据库的名称。

pgAdmin III - 新服务器注册

The default setup is suitable for DBAs et al who can connect to any database on the server, but apparently that isn't true in your case.默认设置适用于 DBA 等人,他们可以连接到服务器上的任何数据库,但显然在您的情况下并非如此。

After you change the Maintenance DB name as suggested by araqnid's answer above , you should also add your database to the DB restrictions field because without this you will see thousands of databases and you may not be able to find yours in the list if the list is too long.按照上面 araqnid 的回答的建议更改维护数据库名称后,您还应该将数据库添加到数据库限制字段中,因为没有这个,您将看到数千个数据库,如果列表是,您可能无法在列表中找到您的数据库太长。

More details here - How to hide databases that I am not allowed to access更多细节在这里 - 如何隐藏我不允许访问的数据库

This is for pgAdmin 4这是用于 pgAdmin 4

In order to connect pgAdmin to your database (postgres instance in Heroku), do the following:为了将 pgAdmin 连接到您的数据库(Heroku 中的 postgres 实例),请执行以下操作:

  1. Login to Heroku, and select the application in which you have the database登录 Heroku,然后选择您拥有数据库的应用程序在此处输入图片说明

  2. Select the Resources tab and then click on "Heroku Postgres Ad-on" (see below).选择“资源”选项卡,然后单击“Heroku Postgres Ad-on”(见下文)。 This will open up a new tab.这将打开一个新选项卡。 在此处输入图片说明

  3. Select the Settings tab and then click on "View Credentials..." (see below)选择设置选项卡,然后单击“查看凭据...”(见下文) 在此处输入图片说明

You will get the following information that you will use in pgAdmin:您将获得将在 pgAdmin 中使用的以下信息:

在此处输入图片说明

  1. Go to pgAdmin, and create a new server转到 pgAdmin,并创建一个新服务器

在此处输入图片说明

  1. In the General tab, give a useful name常规选项卡中,给出一个有用的名称在此处输入图片说明

  2. In the Connection tab, fill the info you got at Heroku连接选项卡中,填写您在 Heroku 上获得的信息在此处输入图片说明

  3. In order to avoid seeing thousands of databases, you need to add your database name to DB restriction in the Advanced tab (see below)为了避免看到数千个数据库,您需要在高级选项卡中将您的数据库名称添加到数据库限制(见下文) 在此处输入图片说明

We require SSL for connections outside heroku.我们需要 SSL 用于 heroku 外部的连接。 Please verify whether you're forcing SSL in your client.请验证您是否在客户端中强制使用 SSL。

Edit:编辑:

Answered more thoroughly here: https://dba.stackexchange.com/questions/21869/connecting-pgadmin3-to-postgres-on-heroku在这里回答更彻底: https : //dba.stackexchange.com/questions/21869/connecting-pgadmin3-to-postgres-on-heroku

We don't allow connections to the postgres database, so be sure to set Maintenance DB to your database name, and be sure to use SSL.我们不允许连接到postgres数据库,因此请务必将维护数据库设置为您的数据库名称,并确保使用 SSL。

That should hopefully suffice.这应该足够了。

Change the Maintenance Database to the name of your Database, eg dva70000p0090.将维护数据库更改为您的数据库的名称,例如 dva70000p0090。 This should work.这应该有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM