PostgreSQL 数据库连接错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17995961/
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
PostgreSQL Database connection error
提问by shashank
Hello i am a beginner to postgresql, I am unable to connect Postgresql database on linux system from windows through pgadmin client . I am getting the following error
您好,我是 postgresql 的初学者,我无法通过 pgadmin 客户端从 windows 连接 linux 系统上的 Postgresql 数据库。我收到以下错误
FATAL: no pg_hba.conf entry for host "192.168.1.42", user "postgres", database "postgres", SSL off
Kindly suggest me how to do.Thanks in advance
请建议我怎么做。提前谢谢
回答by bma
On the db server, edit your pg_hba.conf file and add a line similar to this:
在 db 服务器上,编辑您的 pg_hba.conf 文件并添加类似于以下内容的行:
host all all 192.168.1.42/32 md5
If you don't want to use a password (I won't get into the security aspects), you can switch the "md5" for "trust". If you onlywant to allow the postgres user access to the postgres maintenance database, then switch both "all" words with "postgres" (no quotes).
如果您不想使用密码(我不会涉及安全方面),您可以将“md5”切换为“信任”。如果你只希望允许Postgres的维护数据库的postgres用户访问,然后用“的Postgres”(不含引号)开关兼备“全”字。
You'll need to reload the config files after making any changes. Eg.
进行任何更改后,您需要重新加载配置文件。例如。
pg_ctl reload
or
或者
select pg_reload_conf(); -- as the superuser
If you don't know which pg_hba.conf file your database cluster is using, if you can connect to any of the databases, issue select current_setting('hba_file');
如果您不知道您的数据库集群正在使用哪个 pg_hba.conf 文件,如果您可以连接到任何数据库,请发出 select current_setting('hba_file');
回答by sheplu
by default, postgresql deny all connexion if it's not from "localhost" here is a link for you : https://wiki.debian.org/PhpPgAdmin
默认情况下,postgresql 拒绝所有连接,如果它不是来自“localhost”,这里是一个链接给你:https: //wiki.debian.org/PhpPgAdmin