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 Overflow
🌐
Micro 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....
Discussions

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
🌐 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
🌐 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
🌐 r/PostgreSQL
11
0
December 22, 2023
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
🌐 r/PostgreSQL
20
0
May 23, 2024
🌐
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 ...
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:
🌐
DevArt
blog.devart.com › home › how to › how to create a new database in postgresql
How to create a new database in PostgreSQL?
July 7, 2025 - First of all, click New SQL and type in the CREATE ROLE <username> command into the console window: After that, execute the command by clicking the Execute button. As soon as the application finishes the process, you will see the notification ...
🌐
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.
Find elsewhere
🌐
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)
🌐
Guru99
guru99.com › home › postgresql › how to create database in postgresql
PostgreSQL/Postgres Create Database
3 weeks ago - The syntax to create a database in PostgreSQL is CREATE DATABASE databasename
🌐
PhoenixNAP
phoenixnap.com › home › kb › databases › how to create a database in postgresql
How to Create a Database in PostgreSQL
December 4, 2025 - The createdb command is the third method for creating a database in PostgreSQL. The only difference between the createdb and CREATE DATABASE command is that users run createdb directly from the command line and add a comment into the database, ...
🌐
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.
🌐
StrongDM
strongdm.com › blog › security
Create a Database in PostgreSQL (Step-By-Step Guide)
January 7, 2025 - Learn the step-by-step approach to creating a database in PostgreSQL. Our in-depth guide explores two main methods—using psql and pgAdmin.
🌐
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).
🌐
Neon
neon.com › postgresql › administration › create-database
PostgreSQL CREATE DATABASE Statement
This tutorial shows you how to use the PostgreSQL CREATE DATABASE statement to create new databases with various options.