Re: Problem with initdb: creates database which do not exists - Mailing list pgsql-general

From Thom Brown
Subject Re: Problem with initdb: creates database which do not exists
Date
Msg-id AANLkTinmqyse=JWgkizFayCqe=ouPMFGzo7=JRvVL8A7@mail.gmail.com
Whole thread Raw
In response to Problem with initdb: creates database which do not exists  (Torsten Zühlsdorff <foo@meisterderspiele.de>)
Responses Re: Problem with initdb: creates database which do not exists
List pgsql-general
On 18 October 2010 15:46, Torsten Zühlsdorff <foo@meisterderspiele.de> wrote:
> Hello,
>
> i'm using initdb of an PostgreSQL 8.4 installed over the port-system of
> FreeBSD:
>
> =====
>
>> initdb foo --locale=de_DE.UTF-8 --lc-collate=de_DE.UTF-8
>> --lc-ctype=de_DE.UTF-8 --lc-messages=de_DE.UTF-8 --lc-monetary=de_DE.UTF-8
>> --lc-numeric=de_DE.UTF-8 --lc-time=de_DE.UTF-8
> The files belonging to this database system will be owned by user "thorny".
> This user must also own the server process.
>
> The database cluster will be initialized with locale de_DE.UTF-8.
> The default database encoding has accordingly been set to UTF8.
> The default text search configuration will be set to "german".
>
> creating directory foo ... ok
> creating subdirectories ... ok
> selecting default max_connections ... 100
> selecting default shared_buffers ... 32MB
> creating configuration files ... ok
> creating template1 database in foo/base/1 ... ok
> initializing pg_authid ... ok
> initializing dependencies ... ok
> creating system views ... ok
> loading system objects' descriptions ... ok
> creating conversions ... ok
> creating dictionaries ... ok
> setting privileges on built-in objects ... ok
> creating information schema ... ok
> vacuuming database template1 ... ok
> copying template1 to template0 ... ok
> copying template1 to postgres ... ok
>
> WARNING: enabling "trust" authentication for local connections
> You can change this by editing pg_hba.conf or using the -A option the
> next time you run initdb.
>
> Success. You can now start the database server using:
>
>    postgres -D foo
> or
>    pg_ctl -D foo -l logfile start
>
> =====
>
> After that the database is not visible:
>
> =====
>
>> psql -l
>                           List of databases
>    Name    | Owner  | Encoding | Collation | Ctype | Access privileges
> ------------+--------+----------+-----------+-------+-------------------
>  pgsql      | pgsql  | UTF8     | C         | C     |
>  postgres   | pgsql  | UTF8     | C         | C     |
>  template0  | pgsql  | UTF8     | C         | C     | =c/pgsql
>                                                    : pgsql=CTc/pgsql
>  template1  | pgsql  | UTF8     | C         | C     | =c/pgsql
>                                                    : pgsql=CTc/pgsql
> (4 rows)
>
> =====
>
> So i try again to create it:
>
> =====
>
>> initdb foo --locale=de_DE.UTF-8 --lc-collate=de_DE.UTF-8
>> --lc-ctype=de_DE.UTF-8 --lc-messages=de_DE.UTF-8 --lc-monetary=de_DE.UTF-8
>> --lc-numeric=de_DE.UTF-8 --lc-time=de_DE.UTF-8
> The files belonging to this database system will be owned by user "thorny".
> This user must also own the server process.
>
> The database cluster will be initialized with locale de_DE.UTF-8.
> The default database encoding has accordingly been set to UTF8.
> The default text search configuration will be set to "german".
>
> initdb: directory "foo" exists but is not empty
> If you want to create a new database system, either remove or empty
> the directory "foo" or run initdb
> with an argument other than "foo".
>
> =====
>
> Thats interessting. But i can't drop the database:
>
> =====
>
>> dropdb foo
> dropdb: database removal failed: ERROR:  database "foo" does not exist
>
> =====
>
> So: any idea why the database is not visible? And how do get rid of the
> "non-existing" databases ;)

Hi Torsten.

initdb creates a database cluster, not a database.  What is being
listed is correct.  You either want the createdb command or create it
manually from within psql.  The parameter you're passing is the
directory where the cluster is to be created, so it will appear in the
foo directory relative to wherever you're running that command from.

What you probably want is:

initdb --locale=de_DE.UTF-8 --lc-collate=de_DE.UTF-8
--lc-ctype=de_DE.UTF-8 --lc-messages=de_DE.UTF-8
--lc-monetary=de_DE.UTF-8 --lc-numeric=de_DE.UTF-8
--lc-time=de_DE.UTF-8

createdb -h localhost -p 5432 foo

Regards

Thom Brown
Twitter: @darkixion
IRC (freenode): dark_ixion
Registered Linux user: #516935

pgsql-general by date:

Previous
From: Greg Smith
Date:
Subject: Re: installing from source in Windows
Next
From: Adrian Klaver
Date:
Subject: Re: Problem with initdb: creates database which do not exists