Thread: Problem with initdb: creates database which do not exists

Problem with initdb: creates database which do not exists

From
Torsten Zühlsdorff
Date:
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 ;)

Thanks for your time,
Torsten
--
http://www.dddbl.de - ein Datenbank-Layer, der die Arbeit mit 8
verschiedenen Datenbanksystemen abstrahiert,
Queries von Applikationen trennt und automatisch die Query-Ergebnisse
auswerten kann.

Re: Problem with initdb: creates database which do not exists

From
Thom Brown
Date:
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

Re: Problem with initdb: creates database which do not exists

From
Adrian Klaver
Date:
On Monday 18 October 2010 7:46:21 am Torsten Zühlsdorff 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 ;)
>
> Thanks for your time,
> Torsten
> --
> http://www.dddbl.de - ein Datenbank-Layer, der die Arbeit mit 8
> verschiedenen Datenbanksystemen abstrahiert,
> Queries von Applikationen trennt und automatisch die Query-Ergebnisse
> auswerten kann.

My guess is that you have more than one installation of Postgres. The initdb is
working on one cluster and your psql is pointing at another. You might want to
do a ps to see what is running.

--
Adrian Klaver
adrian.klaver@gmail.com

Re: Problem with initdb: creates database which do not exists

From
Tom Lane
Date:
Adrian Klaver <adrian.klaver@gmail.com> writes:
> On Monday 18 October 2010 7:46:21 am Torsten Z�hlsdorff wrote:
>> So: any idea why the database is not visible? And how do get rid of the
>> "non-existing" databases ;)

> My guess is that you have more than one installation of Postgres. The initdb is
> working on one cluster and your psql is pointing at another.

Yeah.  In particular, since I didn't see any server start or stop
commands in this sequence, it looks like the psql calls are talking to
some pre-existing server process that's using a pre-existing database
directory somewhere else.

            regards, tom lane

Re: Problem with initdb: creates database which do not exists

From
Bill Moran
Date:
In response to Tom Lane <tgl@sss.pgh.pa.us>:

> Adrian Klaver <adrian.klaver@gmail.com> writes:
> > On Monday 18 October 2010 7:46:21 am Torsten Z_hlsdorff wrote:
> >> So: any idea why the database is not visible? And how do get rid of the
> >> "non-existing" databases ;)
>
> > My guess is that you have more than one installation of Postgres. The initdb is
> > working on one cluster and your psql is pointing at another.
>
> Yeah.  In particular, since I didn't see any server start or stop
> commands in this sequence, it looks like the psql calls are talking to
> some pre-existing server process that's using a pre-existing database
> directory somewhere else.

Unless you tweak settings in /etc/rc.conf, FreeBSD's install of Postgres
will start up talking to the DB in /usr/local/pgsql (if you start it
using FreeBSD's rc system)  The port provides the variable postgresql_data
which can be used to change the rc script's behavior.

--
Bill Moran
http://www.potentialtech.com
http://people.collaborativefusion.com/~wmoran/

Re: Problem with initdb: creates database which do not exists

From
Torsten Zühlsdorff
Date:
Thom Brown schrieb:

> initdb creates a database cluster, not a database.  [..]

Now i'm feeling like fool - this is so obviously. -.- I will stop
posting stressed to the Usenet.

I'm sorry. Thanks for your replies and time!

Greetings,
Torsten

--
http://www.dddbl.de - ein Datenbank-Layer, der die Arbeit mit 8
verschiedenen Datenbanksystemen abstrahiert,
Queries von Applikationen trennt und automatisch die Query-Ergebnisse
auswerten kann.

Re: Problem with initdb: creates database which do not exists

From
David Fetter
Date:
On Tue, Oct 19, 2010 at 08:48:13AM +0200, Torsten Zühlsdorff wrote:
> Thom Brown schrieb:
>
> >initdb creates a database cluster, not a database.  [..]
>
> Now i'm feeling like fool - this is so obviously. -.- I will stop
> posting stressed to the Usenet.

Yay, an NNTP user :)

We've all been there.

Cheers,
David.
--
David Fetter <david@fetter.org> http://fetter.org/
Phone: +1 415 235 3778  AIM: dfetter666  Yahoo!: dfetter
Skype: davidfetter      XMPP: david.fetter@gmail.com
iCal: webcal://www.tripit.com/feed/ical/people/david74/tripit.ics

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate