Received: from anchor-post-31.mail.demon.net (anchor-post-31.mail.demon.net [194.217.242.89]) by postgresql.org (Postfix) with ESMTP id 3037C4758EF for ; Sun, 10 Mar 2002 13:58:34 -0500 (EST) Received: from lfix.demon.co.uk ([158.152.59.127] helo=linda.lfix.co.uk) by anchor-post-31.mail.demon.net with esmtp (Exim 3.35 #1) id 16k8Wf-0000yg-0V; Sun, 10 Mar 2002 18:58:33 +0000 Received: from localhost ([127.0.0.1] helo=localhost.localdomain ident=olly) by linda.lfix.co.uk with esmtp (Exim 3.35 #1 (Debian)) id 16k8Wa-0007Wh-00; Sun, 10 Mar 2002 18:58:28 +0000 Subject: Re: create database, user From: Oliver Elphick To: Thorsten Haude Cc: PostgreSQL Novice ML In-Reply-To: <20020310182306.GS808@eumel.yoo.net> References: <20020310182306.GS808@eumel.yoo.net> Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Evolution/1.0.2 Date: 10 Mar 2002 18:58:28 +0000 Message-Id: <1015786708.21922.514.camel@linda> Mime-Version: 1.0 X-Archive-Number: 200203/107 X-Sequence-Number: 3234 On Sun, 2002-03-10 at 18:23, Thorsten Haude wrote: > Hi, > > I want to create a database and a matching user for a web application. > I want to do all that from an SQL file but I have problems with both > 'create database' and 'create user'. > > - I have still not grasped how I should connect to the DBMS for things > like that; there is no root. Is there a document describing best > practices somewhere? It'll be in the docs somewhere; have you read the Administrator's Guide? There is a kind of "root"; it is the "template1" database, which is created when initdb is run. Similarly there is a "root user", the PostgreSQL administrator, who is the user who ran initdb, often "postgres". This user is created with privilege to create both users and databases. To connect in order to create a database, become the adminstrator and either run the script createuser or connect to the "template1" database and use CREATE DATABASE from there. Similarly, use the script createuser or connect to any database and use CREATE USER. > - Are there any special provisions you have to follow to do create > database, user, tables and other object with one SQL file? Put all the commands into a text file, not forgetting the terminating semi-colons where they are needed. For example: $ cat >/tmp/sql.script <