psql:服务器意外关闭了连接 [英] psql: server closed the connection unexepectedly

查看:1439
本文介绍了psql:服务器意外关闭了连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直试图运行通过Postgre DB Server的批处理文件,并运行两个不同的sql文件,如下所示:

I've been trying to run this batch file that goes through the Postgre DB Server and run two different sql files, as shown below:

set PGPASSWORD=blah
cls
@echo on
"C:\Progra~1\pgAdmin III\1.16\psql" -d [db name] -h [server name] -p 5432 -U postgres -f C:\query1.sql
"C:\Progra~1\pgAdmin III\1.16\psql" -d [db name] -h [server name] -p 5432 -U postgres -f C:\query2.sql

但是问题来了,有时我对于query1或query2的命令都会收到以下错误:

But the issue comes that sometimes I will get the following error for either the command for query1 or query2:

psql: server closed the connection unexpectedly 
This probably means the server terminated abnormally
before or while processing the request.

这只是有时发生,所以我不确定为什么会这样。有人可以解释为什么会这样,是否有解决此问题的方法。谢谢!

This only happens sometimes, so I'm not entirely sure why it is happening. Can someone explain why this is the case and if there's a solution to this problem. Thanks!

更新:尝试在实际的Postgre应用程序中打开远程服务器时,有时也会收到相同的错误:发生了错误:服务器关闭了连接
出乎意料,这可能意味着服务器在处理请求之前或期间异常终止了

Update: I also get the same error SOMETIMES when trying to open the remote server in the actual Postgre application: "An error has occured: "server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request."

单击后,我也得到了Guru Hint提示错误弹出窗口之外:

I also get this Guru Hint thing right after I click out of the error popup:

数据库编码
创建数据库VA-trac以使用SQL_ASCII编码存储数据,该编码定义为7位字符
如果只存储;第8位设置的字符(非ASCII字符127-255)的含义未定义,因此服务器无法将数据转换为其他编码。数据库中的非ASCII数据,强烈建议您使用代表您的区域设置字符集的适当数据库编码,以在需要时从自动转换为不同的客户端编码中受益ed。如果将非ASCII数据存储在SQL_ASCII数据库中,则可能会由于代码转换问题而导致写入或读取数据库的怪异字符。使用不同的客户端程序和驱动程序访问数据库时,这可能会使您头疼。
对于大多数安装,Unicode(UTF8)编码将提供最灵活的功能。

Database encoding The database VA-trac is created to store data using the SQL_ASCII encoding. This encoding is defined for 7 bit characters only; the meaning of characters with the 8th bit set (non-ASCII characters 127-255) is not defined. Consequently, it is not possible for the server to convert the data to other encodings. If you're storing non-ASCII data in the database, you're strongly encouraged to use a proper database encoding representing your locale character set to take benefit from the automatic conversion to different client encodings when needed. If you store non-ASCII data in an SQL_ASCII database, you may encounter weird characters written to or read from the database, caused by code conversion problems. This may cause you a lot of headache when accessing the database using different client programs and drivers. For most installations, Unicode (UTF8) encoding will provide the most flexible capabilities.

无论如何,服务器仍然可以打开,之后我就可以访问数据库了。

Regardless, the server still opens up afterward and I'm able to access the database from that point on.

推荐答案

在此处保留信息,

如果PostgreSQL服务器在另一台计算机上并且是不监听外部接口

This error can also be caused if PostgreSQL server is on another machine and is not listening on external interfaces.

要调试此特定问题,您可以按照以下步骤操作:

To debug this specific problem, you can follow theses steps:


  • 查看您的postgresql.conf, sudo vim /etc/postgresql/9.3/main/postgresql.conf

  • 添加此行: listen_addresses ='*'

  • 重新启动服务 sudo / etc /init.d/postgresql restart

  • Look at your postgresql.conf, sudo vim /etc/postgresql/9.3/main/postgresql.conf
  • Add this line: listen_addresses = '*'
  • Restart the service sudo /etc/init.d/postgresql restart

(注意,以上命令用于ubuntu。其他Linux发行版或操作系统可能对这些文件有不同的路径)

(Note, the commands above are for ubuntu. Other linux distro or OS may have different path to theses files)

注意:使用'*'来监听地址会监听所有接口。如果您执行'0.0.0.0',则它将监听所有ipv4,如果您执行'::'然后它将监听所有ipv6。

Note: using '*' for listening addresses will listen on all interfaces. If you do '0.0.0.0' then it'll listen for all ipv4 and if you do '::' then it'll listen for all ipv6.

http://www.postgresql.org/docs/9.3/static/runtime-config-connection.html

这篇关于psql:服务器意外关闭了连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆