PostgreSQL

From Programvareverkstedet

English


Bruk av PostgreSQL på PVV

PVVs PostgreSQL-databasetjener heter postgres.pvv.ntnu.no. Den aksepterer tilkoblinger fra alle maskinene på PVV, og alle brukere kan opprette så mange databaser de vil.

Oppretting av bruker og database

For å opprette brukere og databaser i PVVs PostgreSQL-server kan verktøyene /local/bin/psql-useradm og /local/bin/psql-dbadm brukes. Du finner disse verktøyene ved å logge inn på PostgreSQL-serveren med SSH. Kjør verktøyene uten argumenter for å få informasjon om hvordan du bruker dem. Disse verktøyene er bare en samling av de nyttigste funksjonene til de mer tradisjonelle postgres vertøyene som for eksempel psql, createdb etc, men psql-user/dbadm opprettholder navneregler og rettigheter for nye databaser bedre enn de tradisjonelle verktøyene. Merk at både brukernavnet og databasen må begynne på ditt brukernavn. Tillatte former er brukernavn eller brukernavn_tillegg. Kildekoden til psql-useradm og psql-dbadm er åpent tilgjengelig. Du finner den på http://www.pvv.ntnu.no/~eirikald/projects/psqladm.tar.bz2

Mer finkornet tilgangskontroll

Dersom du ønsker mer detaljert tilgangskontroll enn bare å velge eier av databasen, kan du opprette noen ekstra brukere med psql-useradm og bruke de vanlige tilgangsfunksjonene til PostgreSQL. Se PostgreSQL-manualen for informasjon om syntaksen.

Eksempel

psql-usradm brukernavn_testbruker
//skriv passord
psql-dbadm brukernavn_testbruker brukernavn_testdatabase
psql -h postgres.pvv.ntnu.no -U brukernavn_testbruker brukernavn_testdatabase
//skriv passord

PostgreSQL

Use of PostgreSQL at PVV

PVVs PostgreSQL database server is called postgres.pvv.ntnu.no. It accepts connections from all the machines at PVV, and all users can create as many databases as they want.

Setup of User and Database

To set up users and databases in PVVs PostgreSQL server the tools code>/local/bin/psql-useradm and /local/bin/psql-dbadm can be used. You find these tools by logging in to the PostgreSQL server by SSH. Run the tools without arguments to get information on how to use them. These tools are just a collection of the most useful functions of the more traditional postgres tools like for an instance psql, createdb etc, but psql-user/dbadm maintains naming rules and rights for new databases better than the traditional tools. Note that both the username and database must start with your username. Allowed forms are username or username_addittion. The source code to the psql-useradm and psql-dbadm are openly available. You find them at http://www.pvv.ntnu.no/~eirikald/projects/psqladm.tar.bz2.

More fine grained access control

If you wish a more detailed access control than just selecting an owner of the database, you can maintain som additional users with psql-useradm and use the ordinary access functions of PostgreSQL. See the PostgreSQL manual for information on the syntax.

Example

psql-usradm username_testuser
//Enter password
psql-dbadm username_testuser username_testdatabase
psql -h postgres.pvv.ntnu.no -U username_testuser username_testdatabase
//Enter password