Received: from post.webmailer.de (natpost.webmailer.de [192.67.198.65]) by postgresql.org (Postfix) with ESMTP id 309464759A7 for ; Sun, 10 Mar 2002 14:53:18 -0500 (EST) Received: from eumel.yoo.net (pD952C457.dip.t-dialin.net [217.82.196.87]) by post.webmailer.de (8.9.3/8.8.7) with ESMTP id UAA11735 for ; Sun, 10 Mar 2002 20:53:18 +0100 (MET) Received: by eumel.yoo.net (Postfix on SuSE Linux 7.2 (i386), from userid 500) id 50A341262C; Sun, 10 Mar 2002 21:04:45 +0100 (CET) Date: Sun, 10 Mar 2002 21:04:45 +0100 From: Thorsten Haude To: PostgreSQL Novice ML Subject: Re: create database, user Message-ID: <20020310200445.GT808@eumel.yoo.net> Mail-Followup-To: PostgreSQL Novice ML References: <20020310182306.GS808@eumel.yoo.net> <1015786708.21922.514.camel@linda> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1015786708.21922.514.camel@linda> User-Agent: Mutt/1.3.24i X-Warning: Email may contain unsmilyfied humor and/or satire. Keywords: Netz gegen Kinderporno Organization: Ministry of Information, Department of Works X-Archive-Number: 200203/109 X-Sequence-Number: 3236 Hi, * Oliver Elphick [02-03-10 19:58]: >On Sun, 2002-03-10 at 18:23, Thorsten Haude wrote: >> 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? Not the whole thing, but anything I thought would be useful. Not enough (thought) obviously. >> - 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. I did that, and one of the problems was solved by \connect. It never occured to me that you can use the backslash commands in a file. The other problem is a password though. I changed one line in your example to: CREATE USER junk_user encrypted password 'secret'; And it fails: ERROR: parser: parse error at or near "encrypted" What's wrong here? >Whether the above script succeeds in changing user depends on how >pg_hba.conf is set up. If pg_hba.conf doesn't allow the connection, the >script will fail at the \connect. You need the \connect, otherwise the >table would be created in template1 rather than in the new database. I checked, and it should work. Thank you very much for your help! Thorsten -- The opposite of the above statement is also true.