3 postgresql perl tcp dbi
我相信我已经正确设置了Pg,但我的脚本似乎没有连接到数据库.我正在测试:
$database="networkem";
$user="postgres";
$password="";
$host="localhost";
$dbh = DBI->connect("DBI:Pg:dbname=$dbname;host=$host", $user, $password);
我的pg_hba读到:
host all postgres 127.0.0.1 255.255.255.255 trust
我可以psql通过命令行使用,并使用-i选项启动postmaster.我错过了什么?
我还尝试了另一个通过psql正常工作的用户:
$user="jimbo"; $password="p2ssw0rd";
与pg_hba阅读:
host all jimbo 127.0.0.1 255.255.255.255 trust
Sch*_*ern 11
而不是播放20个问题来调试您的设置,DBI->errstr将说明连接失败的原因.
my $dbh = DBI->connect(...) or die DBI->errstr;
Run Code Online (Sandbox Code Playgroud)
虽然如果我不得不猜测...因为Postgres基于主机和登录用户进行身份验证,我怀疑你给Postgres连接的用户名和你登录的Unix用户之间的混淆.