Read this tutorial it has got everyting you need to know about psql. Document herewith attached On Sat, 23 Sep 2000, Chris wrote: > Greetings, > > When ever a normal user (anyaccount besides "postgres") tries to > run psql they get the following message: > > Connection to database 'dank' failed. > FATAL 1: SetUserId: user "chrisp" is not in "pg_shadow" > > > How do i fix this?
{\rtf1\ansi\deflang1024\deff0{\fonttbl{\f0\froman Times Roman;}{\f1\fnil Times;}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;}{\stylesheet{\sl240\slmult1\brdrt0\brdrl0\brdrr0\brdrb0\brdrbtw0 \f1\fs24\cf1 \snext0 Normal;}{\s1\sl240\slmult1 \brdrt0\brdrl0\brdrr0\brdrb0\brdrbtw0 \f1\fs24\cf1 \sbasedon0\snext1 Cell;}{\s2\sl240\slmult1\brdrt0\brdrl0\brdrr0\brdrb0\brdrbtw0 \f1\fs24\cf1 \sbasedon0\snext2 Footnote;}{\s3\sl240\slmult1\tqc\tx5040\tqr\tx10080\tqr\tx13680\brdrt0\brdrl0\brdrr0 \brdrb0\brdrbtw0 \f1\fs24\cf1 \sbasedon0\snext3 HdrFtr;}{\s4\sl240\slmult1\brdrt0\brdrl0\brdrr0\brdrb0\brdrbtw0 \ul\f1\fs24\cf2 \sbasedon0\snext4 html_hyperlink_text;}} {\info{\title ax00500e.aw}{\author dannyh}{\doccomm Created by ApplixWare Release 4.42 (build 1021.522) #17 RTF Export Filter}} \paperw12240\paperh15840\margl1080\margr1080\margt1440\margb1440\widowctrl\ftnbj\sectd\marglsxn1080\margrsxn1080\margtsxn1440\margbsxn1440\sbknone\headery360\footery360\endnhere\pard\plain \slmult1 \f1\fs24\cf1 Adding a user \par I like the way PostgreSQL works. It creates a special user for you, pgsql. This user does all the work. The database run as this user, and all work \par (database creation, adding users, etc) is done as this user. \par \par The first step is to add myself as a user, so I don't have to do all my work as pgql. Here's how I added myself as a user. I typed the bits in bold. \par \par $ su -l \par Password: \par [root@set:~] # su pgsql \par $ /usr/local/pgsql/bin/createuser dan \par Shall the new user be allowed to create databases? (y/n) y \par Shall the new user be allowed to create more new users? (y/n) y \par CREATE USER \par \par Done. Now that I've added myself as a user who can create databases, I can use my normal login. \par Adding a database \par Now I dropped back to my usual login and created a database. \par \par $ logout \par [root@set:~] # logout \par [dan@set:/usr/home/dan] $ /usr/local/pgsql/bin/createdb mydb \par CREATE DATABASE \par \par Done. \par Creating a user for this database \par Now I dropped back to my usual login and created a database. \par \par $ /usr/local/pgsql/bin/psql mydb \par Welcome to psql, the PostgreSQL interactive terminal. \par \par Type: \\copyright for distribution terms \par \\h for help with SQL commands \par \\? for help on internal slash commands \par \\g or terminate with semicolon to execute query \par \\q to quit \par \par mydb=# \par \par Now I'll create a user, tester, for this database. \par \par mydb=# create user tester with password 'mypassword'; \par CREATE USER \par \par Creating a table \par I created a rather simple table for my testing. \par \par mydb=# create table test (id serial, name varchar(10)); \par NOTICE: CREATE TABLE will create implicit sequence 'test_id_seq' \par for SERIAL column 'test.id' \par NOTICE: CREATE TABLE/UNIQUE will create implicit index 'test_id_key' \par for table 'test' \par CREATE \par \par Then I inserted data: \par \par mydb=# insert into test (name) values ('test'); \par INSERT 18879 1 \par mydb=# insert into test (name) values ('test2'); \par INSERT 18880 1 \par \par Then I read that data back out: \par \par freshports2=# select * from test; \par id | name \par ----+------- \par 1 | test \par 2 | test2 \par (2 rows) \par \par Getting php going \par I create a simple php test in an existing website. For help on creating websites, look at Apache - virtual hosts. \par \par I added this to testpsql.php3 in my website. Note the amended while loop at the end of this section. \par \par <head> \par <title>PostgreSQL test</title> \par <body> \par \par <?php \par $database = pg_connect("dbname=mydb user=test password=mypassword"); \par if ($database) \{ \par $result = pg_exec ($database, "select * from test"); \par if ($result) \{ \par echo pg_numrows($result) . " rows to fetch\\n"; \par echo "<table>\\n"; \par $i = 0; \par while ($myrow = pg_fetch_array ($result)) \{ \par $i++; \par echo " <tr><td>" . $myrow["id"] . "</td><td>" . \par $myrow["name"] . "</td></tr>\\n"; \par if ($i > 10) break; \par \} \par echo "</table>\\n"; \par \} else \{ \par echo "read from test failed"; \par \} \par \par pg_exec ($database, "end"); \par \} else \{ \par echo "no connection"; \par \} \par ?> \par \par </body></html> \par \par As you can see, I had to manually break the loop. I have no idea why. I thought pg_fetch_array would return false at the end of the result set, as \par mentioned in the documentation. But it didn't. So far, it appears I'll have to use a for loop for that and not a while. Any ideas on why \par pg_fetch_array was behaving like that? It seems to be standard behaviour. \par \par A search at http://google.com found this example, which I used to create this amended while loop: \par \par for ($i = 0; $i < $NumRows; $i++) \{ \par $myrow = pg_fetch_array ($result, $i); \par echo " <tr><td>" . $myrow["id"] . "</td><td>" . $myrow["name"] . \par "</td></tr>\\n"; \par \} \par \par What's next? \par I would like a Windows GUI inteface to PostgreSQL. Any suggestions? I found ZEOS, but couldn't get it to connect. I suspect someone wrong \par with my access rights, but I was looking at /usr/local/pgsql/lib/pg_hba.conf. \par }