Обсуждение: Connecting via perl gives "root" does not exist
I'm new at PostgreSQL. So far, succesfully compiled & installed it. Created a db, created a table, and 'copied' tab-delim data into it. Also downloaded and installed Perl Pg mod (that was a pain; had to sen ENV variables, and had to force install because of the "root" does not exist error in make test). Here's the example script from the Pg readme (with my own db info): use Pg; $conn = Pg::connectdb("dbname=tasbill"); $res = $conn->exec("SELECT * from cust"); while (@row = $res->fetchrow) { print join(" ", @row); } Works fine if I log in as 'postgres' before executing script, but fails if logged in as any other user. I'm using the default pg_hba.conf file, which I thought would allow local users to connect to any database: local all trust host all 127.0.0.1 255.255.255.255 trust What am I missing?? -- Randy Perry sysTame Mac Consulting/Sales
> use Pg; > $conn = Pg::connectdb("dbname=tasbill"); > $res = $conn->exec("SELECT * from cust"); > while (@row = $res->fetchrow) { > print join(" ", @row); > } > > > Works fine if I log in as 'postgres' before executing script, but fails if > logged in as any other user. I'm using the default pg_hba.conf file, which I > thought would allow local users to connect to any database: > > local all trust > host all 127.0.0.1 255.255.255.255 trust > > What am I missing?? Either one or both of following: 1. Use proper user name in connectdb() call 2. Run 'createuser <username>' on the server side, where <username> belongs to the user running the client script. pg_hba.conf decides what hosts can connect and *how* to authenticate users names. It does not control user access. That's what createuser and GRANT queries are for. --Gene
on 4/22/01 11:25 PM, selkovjr@mcs.anl.gov at selkovjr@mcs.anl.gov wrote: >> use Pg; >> $conn = Pg::connectdb("dbname=tasbill"); >> $res = $conn->exec("SELECT * from cust"); >> while (@row = $res->fetchrow) { >> print join(" ", @row); >> } >> >> >> Works fine if I log in as 'postgres' before executing script, but fails if >> logged in as any other user. I'm using the default pg_hba.conf file, which I >> thought would allow local users to connect to any database: >> >> local all trust >> host all 127.0.0.1 255.255.255.255 trust >> >> What am I missing?? > > Either one or both of following: > > 1. Use proper user name in connectdb() call > > 2. Run 'createuser <username>' on the server side, where <username> > belongs to the user running the client script. > > pg_hba.conf decides what hosts can connect and *how* to authenticate > users names. It does not control user access. That's what createuser > and GRANT queries are for. > > --Gene > Thanks. Did try createuser and grant commands, but forgot to end with ';'. Re-did it and it works. -- Randy Perry sysTame Mac Consulting/Sales
For other users, you have to provide username and password which should existed in your db. Jie LIANG St. Bernard Software 10350 Science Center Drive Suite 100, San Diego, CA 92121 Office:(858)320-4873 jliang@ipinc.com www.stbernard.com www.ipinc.com On Sun, 22 Apr 2001, Randall Perry wrote: > I'm new at PostgreSQL. > > So far, succesfully compiled & installed it. Created a db, created a table, > and 'copied' tab-delim data into it. > > Also downloaded and installed Perl Pg mod (that was a pain; had to sen ENV > variables, and had to force install because of the "root" does not exist > error in make test). > > Here's the example script from the Pg readme (with my own db info): > > use Pg; > $conn = Pg::connectdb("dbname=tasbill user=foo password=bar"); > $res = $conn->exec("SELECT * from cust"); > while (@row = $res->fetchrow) { > print join(" ", @row); > } > > > Works fine if I log in as 'postgres' before executing script, but fails if > logged in as any other user. I'm using the default pg_hba.conf file, which I > thought would allow local users to connect to any database: > > local all trust > host all 127.0.0.1 255.255.255.255 trust > > What am I missing?? > > > > -- > Randy Perry > sysTame > Mac Consulting/Sales > > > > > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://www.postgresql.org/search.mpl >