Sample Header Ad - 728x90

What steps are required to setup PostgreSQL and create a db in Windows?

0 votes
1 answer
1057 views
I have installed PostgreSQL 12 from https://www.2ndquadrant.com/en/blog/pginstaller-install-postgresql/ . and put \C:\...\PostgreSQL\12\bin in the PATH. In an admin powershell I execute psql.exe -U postgres and enter the password I chose in the installation wizard. Now I'm in a shell. I want to create a database so I run createdb but it seems the database is not created:
postgres-# \l
                                          List of databases
   Name    |  Owner   | Encoding |       Collate       |        Ctype        |   Access privileges
-----------+----------+----------+---------------------+---------------------+-----------------------
 postgres  | postgres | UTF8     | German_Germany.1252 | German_Germany.1252 |
 template0 | postgres | UTF8     | German_Germany.1252 | German_Germany.1252 | =c/postgres          +
           |          |          |                     |                     | postgres=CTc/postgres
 template1 | postgres | UTF8     | German_Germany.1252 | German_Germany.1252 | =c/postgres          +
           |          |          |                     |                     | postgres=CTc/postgres
(3 rows)


postgres-# createdb demo
postgres-# absolute nonsense
postgres-# \l
                                          List of databases
   Name    |  Owner   | Encoding |       Collate       |        Ctype        |   Access privileges
-----------+----------+----------+---------------------+---------------------+-----------------------
 postgres  | postgres | UTF8     | German_Germany.1252 | German_Germany.1252 |
 template0 | postgres | UTF8     | German_Germany.1252 | German_Germany.1252 | =c/postgres          +
           |          |          |                     |                     | postgres=CTc/postgres
 template1 | postgres | UTF8     | German_Germany.1252 | German_Germany.1252 | =c/postgres          +
           |          |          |                     |                     | postgres=CTc/postgres
(3 rows)
I assume that my command createdb demo fails without error response as the intentionally wrong next command absolute nonsense fails as well. But I don't know how else to create a db, and moreover I'd like to know why this doesn't work and how to debug this.
Asked by user2740 (157 rep)
Sep 7, 2020, 08:42 AM
Last activity: Sep 7, 2020, 09:25 AM