Skip to main content
⚡ OpenDevDocs
PostgreSQL
databasepostgresqlReferenceBeginner

Create PostgreSQL Database (createdb)

Create a new PostgreSQL database directly from the terminal using the createdb command-line utility.

Verified: 2026-09-30
Tested on:postgres 16.x
Platforms:
linuxmacoswindows
#postgresql#createdb#cli#database

Command

createdb -h localhost -U postgres -O db_owner database_name


Short Description

createdb is a command-line wrapper around the SQL command CREATE DATABASE.


Examples

1. Create Database with Specific Owner

createdb -U postgres -O app_user production_db

2. Create Database with UTF-8 Encoding

createdb -U postgres -E UTF8 -O app_user analytics_db

On this page