database PGAdmin:未连接到服务器或与服务器的连接已关闭

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/41266659/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 08:03:40  来源:igfitidea点击:

PGAdmin: Not connected to the server or the connection to the server has been closed

databasepostgresqlpgadminpgadmin-4

提问by Jorge

i got this problem with postgreSQL, when i do a simple query of anything (CRUD), sometimes it works and almost always shows this message:

我在使用 postgreSQL 时遇到了这个问题,当我对任何东西(CRUD)进行简单查询时,有时它会起作用并且几乎总是显示此消息:

Not connected to the server or the connection to the server has been closed.

未连接到服务器或与服务器的连接已关闭。

I don't know how to solve it and it started to irritate me, anyone know how to fix it?

我不知道如何解决它,它开始激怒我,有人知道如何解决它吗?

UPDATE 1

更新 1

I have been searching and it seems the pgadmin4 the problem (it seems because it's not 100% developed yet), i have been using pgadmin3 and that error doesn't show up.

我一直在搜索,似乎 pgadmin4 有问题(似乎是因为它还没有 100% 开发),我一直在使用 pgadmin3,但没有出现该错误。

回答by lucidbrot

The reason this happened for me was a syntax error in the query. Check your syntax and try again, maybe this suffices

发生这种情况的原因是查询中的语法错误。检查您的语法并重试,也许这就足够了

回答by Murtuza Z

This issue has been fixed.

这个问题已被解决。

Upgrade to pgAdmin4 version 2.0. https://www.pgadmin.org/download/

升级到 pgAdmin4 2.0 版。https://www.pgadmin.org/download/

回答by WISAM

solution is:

解决办法是:

select the database where you lost the connection.

选择失去连接的数据库。

then on the right hand side select SQL

然后在右侧选择 SQL

For example in the picture (shopdb) is the db where I lost the connection to.

例如在图片中 (shopdb) 是我失去连接的数据库。

enter image description hereAfter that PgAdmin will ask you if you would like to reconnect to this database... enter image description hereclick ok

在此处输入图片说明之后 PgAdmin 会问你是否要重新连接到这个数据库... 在此处输入图片说明点击确定

you will notice a message retreiving data from the server

您会注意到一条消息正在从服务器检索数据

回答by Alexander Chandra

I have similiar problem before, im using postgre 9.6.1-1 I can do select without condition (ex: select * from foodtable) and i can do insert too.. But if i do select or edit or delete using a condition (ex: select * from foodtable where taste='sweet') the output is like your

我之前有类似的问题,我使用 postgre 9.6.1-1 我可以不带条件地选择(例如:),我也select * from foodtable可以插入......但是如果我使用条件(例如:)选择或编辑或删除select * from foodtable where taste='sweet'输出就像你的

Not connected to the server or the connection to the server has been closed.

未连接到服务器或与服务器的连接已关闭。

I try reinstall (After uninstall delete all leftover data) and delete C:\Users\yourUserName\AppData\Roaming\pgAdmin (delete all data inside pgAdmin Folder) And its works

我尝试重新安装(卸载后删除所有剩余数据)并删除 C:\Users\yourUserName\AppData\Roaming\pgAdmin(删除 pgAdmin 文件夹中的所有数据)及其工作原理

Update-> Your table name and field name must lowercase

更新->你的表名和字段名必须小写

回答by iqra

just change the column name and run the query , it worked for me.

只需更改列名并运行查询,它对我有用。

my column name was timestamp, it conflicted with datatypeso i changed timestampby _timestamp

我的列名是时间戳,它与数据类型冲突,所以我通过_timestamp更改了时间戳

回答by Murtuza Z

Can you run & provide output of these sql queries from pgAdmin4?

你能从 pgAdmin4 运行并提供这些 sql 查询的输出吗?

1) SHOW SERVER_ENCODING;
2) SHOW CLIENT_ENCODING;

And what is the encoding set for your current database connection on which you are trying to run query (Right click on your database, click on Properties > Definition Tab > Check Encoding, Collation & Character type) ?

您尝试运行查询的当前数据库连接的编码集是什么(右键单击您的数据库,单击“属性”>“定义”选项卡>“检查编码、排序规则和字符类型”)?

I'm suspecting you are facing issues due to encoding.

我怀疑您因编码而面临问题。

回答by josedlujan

Change the versión of pgAdmin, use pgAdmin 3, its a problem frequently between Windows 10 and pgAdmin4.

更改 pgAdmin 的版本,使用 pgAdmin 3,这是 Windows 10 和 pgAdmin4 之间经常出现的问题。

回答by S. Koshelnyk

I solved this. I pressed F7 or Explain in drop-down list near the Execute button. Then I saw where exactly the trouble was. pgAdmin4 didn`t like the name of my column. Then I went to problem column and renamed it.

我解决了这个问题。我在“执行”按钮附近的下拉列表中按了 F7 或解释。然后我看到了问题究竟出在哪里。pgAdmin4 不喜欢我的专栏名称。然后我去了问题列并重命名了它。

回答by Momchill

I was getting this error when running a long series of queries in a transaction. Then when I ran them separately, it didn't loose the connection. Still no idea why it actually happens...

在事务中运行一长串查询时出现此错误。然后当我分别运行它们时,它并没有断开连接。仍然不知道为什么它实际上会发生......

回答by iCpu

Juuuuust in case someone googled this post like i did. If you have JSONcolumn AND you want to see ANY result in pgAdmin, cast JSON into VARCHAR like

Juuuuust 以防有人像我一样用谷歌搜索这篇文章。如果您有JSON列并且您想在 pgAdmin 中看到任何结果,请将 JSON 转换为 VARCHAR,例如

SELECT id, metadata::VARCHAR FROM data_table; 

It doesn't matter if content is NULL or not, JSONdoesn't work. Maybe there are other types or values that can't be parsed by pgAdmin as well.

内容是否为 NULL 并不重要,JSON不起作用。也许还有其他类型或值无法被 pgAdmin 解析。

Note: you can still insert values and recieve them after cast, so the problem is on JS side (put one more coin into your "Hate JS" jar).

注意:您仍然可以插入值并在转换后接收它们,因此问题出在 JS 方面再将一枚硬币放入您的“Hate JS”jar)