Change the user to postgres :
su - postgres
Create User for Postgres (in the shell and NOT with psql)
$ createuser testuser
Create Database (same)
$ createdb testdb
Acces the postgres Shell
psql ( enter the password for postgressql)
Provide the privileges to the postgres user
$ alter user testuser with encrypted password 'qwerty';
$ grant all privileges on database testdb to testuser;
Answer from django-renjith on Stack OverflowMicro Focus
microfocus.com › documentation › idol › IDOL_12_0 › MediaServer › Guides › html › English › Content › Getting_Started › Configure › _TRN_Set_up_PostgreSQL.htm
Set Up a PostgreSQL Database on Windows - Micro Focus
This step enables you to use the ... file path in the Command Prompt to start psql. ... Enter your password when prompted. Run a CREATE DATABASE command to create a new database....
Top answer 1 of 11
394
Change the user to postgres :
su - postgres
Create User for Postgres (in the shell and NOT with psql)
$ createuser testuser
Create Database (same)
$ createdb testdb
Acces the postgres Shell
psql ( enter the password for postgressql)
Provide the privileges to the postgres user
$ alter user testuser with encrypted password 'qwerty';
$ grant all privileges on database testdb to testuser;
2 of 11
163
Try:
sudo -u postgres psql -c 'create database test;'
batch file - psql.exe postgresql create database via CMD - Stack Overflow
I search to create a database via CMD, i success to create it using this command: C:\>"C:\Program Files\PostgreSQL\9.3\bin\psql.exe" -U postgres template1 So when i excute this command i can Cr... More on stackoverflow.com
What steps are required to setup PostgreSQL and create a db in Windows? - Database Administrators Stack Exchange
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 More on dba.stackexchange.com
Running createdb from CLI - how does that work?
createdb/createuser and similar are virtually the same as: psql -d postgres -c "create database ..." They start connection to database, run sql command that does what is necessary, and exit. Does it help, or is something not clear? More on reddit.com
How do I simply navigate to a folder and create a database file there with BASH?
postgresql is service, usually only one in one server and it stores files into data folder. If you want really simple database then use SQLite. More on reddit.com
Installing and Creating Database in PostgreSQL
10:05
Install PostgreSQL on Windows (Beginner Tutorial) | Create Your ...
How to create database using PSQL SQL shell for PostgreSQL - YouTube
05:54
How To Create A Database In PostgreSQL 16 Using pgAdmin 4 Or psql ...
Create database in postgreSQL Server Using SQL Shell ...
05:11
How to install PostgreSQL on windows | create database | restore ...
Super User
superuser.com › questions › 1800694 › how-do-i-set-up-a-postgresql-database-in-windows-powershell
How do I set up a postgresql database in Windows Powershell? - Super User
July 27, 2023 - Alternatively, you can use the Postgres shell and enter user details based on the prompts given, and then create a database using CREATE DATABASE database1;. ... Find the answer to your question by asking.
CommandPrompt Inc.
commandprompt.com › education › how-to-create-a-postgres-database-from-command-line
How to Create a Postgres Database From Command Line — CommandPrompt Inc.
August 17, 2023 - PostgreSQL supports various commands to create a database from the command line, including “createdb” and “CREATE DATABASE”. For instance, executing the “CREATE DATABASE” command from SQL Shell creates a new Postgres database, while ...
Call +1-503-667-4564
Address 2950 Newmarket ST STE 101 - 231, 98226, Bellingham
PostgreSQL
postgresql.org › docs › current › tutorial-createdb.html
PostgreSQL: Documentation: 18: 1.3. Creating a Database
May 14, 2026 - A running PostgreSQL server can manage many databases. Typically, a separate database is used for each project or for each user. Possibly, your site administrator has already created a database for your use. In that case you can omit this step and skip ahead to the next section. To create a new database from the command line, in this example named mydb, you use the following command:
TutorialsPoint
tutorialspoint.com › postgresql › postgresql_create_database.htm
PostgreSQL - CREATE Database
This chapter discusses about how to create a new database in your PostgreSQL. PostgreSQL provides two ways of creating a new database − · Using CREATE DATABASE, an SQL command. Using createdb a command-line executable.
PostgreSQL
postgresql.org › docs › current › manage-ag-createdb.html
PostgreSQL: Documentation: 18: 22.2. Creating a Database
May 14, 2026 - In order to create a database, the PostgreSQL server must be up and running (see Section 18.3). Databases are created with the SQL command CREATE DATABASE:
DbSchema
dbschema.com › blog › postgresql › postgresql create database guide with psql and dbschema | dbschema
PostgreSQL CREATE DATABASE Guide with psql and DbSchema | DbSchema
May 11, 2023 - In this article, we'll explore both tools and show you how to create a database using psql, a Postgres command-line client, and DbSchema, a visual database designer. Before we begin, ensure that you have the following: A computer with a compatible operating system (Windows, macOS, or Linux)
Medium
medium.com › @zum.hatice › how-to-create-a-postgresql-db-and-connect-in-windows-b26eaa48c7fb
How to Create a Postgresql DB and Connect in Windows | by Hatice Zümrüt | Medium
February 27, 2024 - And with the double click to ‘Path’, you will reach to last window to add Postgresql path. Just click ‘New’ and write the path to your PostgreSql bin folder. Usually the path forms as ‘main_path\PostgreSQL\version_number\bin’. Just click to OK to save the chages and we have Postgresql enabled. With an easy way you may use cmd (terminal) to create a brand new postgresql database in your postgresql server.
w3resource
w3resource.com › PostgreSQL › create-database.php
PostgreSQL Create Database - w3resource
April 1, 2026 - This document discusses how to create a database in PostgreSQL using the command line, pgAdmin III, and phppgAdmin. For ease of understanding, each process is complemented by screenshots taken while doing. ... Now run the following command to create a database. ... This command creates a database w3r. The following table describes errors you may encounter while creating a database using "createdb". ... Start pgAdmin III and (in linux from Application > Programs > pgAdmin III and in Windows All Programs > PostgreSQL 9.1 > pgAdmin III) and reach "Databases" under your Server menu in right-hand side pane of your pgAdmin III window.
Vinchin
vinchin.com › home › database tips › how to create a postgres database using command line and pgadmin?
How to Create a Postgres Database Using Command Line and pgAdmin? | Vinchin Backup
October 10, 2025 - To view all databases—including size/details—type: ... This uses current OS user credentials unless otherwise specified (createdb -U username dbname). For more options about templates/encoding/ownership run createdb --help or consult official documentation. Not everyone enjoys typing commands—pgAdmin provides an intuitive graphical interface available on Windows/macOS/Linux systems. Begin by launching pgAdmin, then connect it to your PostgreSQL server if not already set up:
PostgreSQL
postgresql.org › docs › current › sql-createdatabase.html
PostgreSQL: Documentation: 18: CREATE DATABASE
May 14, 2026 - In particular, by writing TEMPLATE template0, you can create a pristine database (one where no user-defined objects exist and where the system objects have not been altered) containing only the standard objects predefined by your version of PostgreSQL. This is useful if you wish to avoid copying any installation-local objects that might have been added to template1. ... The name of a database to create. ... The role name of the user who will own the new database, or DEFAULT to use the default (namely, the user executing the command).
Top answer 1 of 2
2
You get that error because template1 is not the last argument. You can use -d to specify the database.
Use the database postgres instead of template1.
Try this:
"C:\Program Files\PostgreSQL\9.3\bin\psql.exe" -U postgres -d postgres -c "CREATE DATABASE t"
2 of 2
2
https://www.postgresql.org/docs/9.3/static/app-psql.html
see --command=command section
PostgreSQL
postgresql.org › docs › 10 › sql-createdatabase.html
PostgreSQL: Documentation: 10: CREATE DATABASE
November 10, 2022 - CREATE DATABASE creates a new PostgreSQL database.