Create database with PostgreSQL

Last modified: August 9, 2009 - 13:53

The database must be created with UTF-8 (Unicode) encoding.

1. CREATE DATABASE USER

This step is only necessary if you don't already have a user setup (e.g. by your host) or you want to create new user for use with Drupal only. The following command creates a new user named "username" and asks for a password for that user:

createuser --pwprompt --encrypted --no-adduser --no-createdb username

If everything works correctly, you'll see a "CREATE USER" notice.

2. CREATE THE DRUPAL DATABASE

This step is only necessary if you don't already have a database setup (e.g. By your host) or you want to create new database for use with Drupal only. The following command creates a new database named "databasename", which is owned by previously created "username":

createdb --encoding=UNICODE --owner=username databasename

If everything works correctly, you'll see a "CREATE DATABASE" notice.

Corrected PG commands

mcm.drupal - October 6, 2007 - 02:47

Those commands are from a shell prompt, I guess.

From inside psql, you would use:

create user username with password 'whatever' nocreateuser nocreatedb;
and
create database with owner=username encoding='UNICODE';

Editing sites/default/default.settings.php

mikehoward - March 18, 2008 - 15:20

change the line:
$db_url = 'mysql://username:password@localhost/databasename';

to

$db_url = 'pgsql://username:password@localhost/databasename';

 
 

Drupal is a registered trademark of Dries Buytaert.