aboutsummaryrefslogtreecommitdiff
path: root/src/man/createdb.1
blob: 8aba472accb6316c220ca67b445554a8e84d0620 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
.\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here....
.\" $Header: /cvsroot/pgsql/src/man/Attic/createdb.1,v 1.13 1998/10/14 02:54:30 momjian Exp $
.TH CREATEDB UNIX 11/05/95 PostgreSQL PostgreSQL
.SH NAME
createdb - create a database
.SH SYNOPSIS
.BR createdb
[\c
.BR -a
system]
[\c
.BR -h
host]
[\c
.BR -p
port]
[\c
.BR "-u"]
[\c
.BR -D
location]
[dbname]
.SH DESCRIPTION
.BR createdb
creates a new database.  The person who executes this command becomes
the database administrator, or DBA, for this database and is the only
person, other than the Postgres super-user, who can destroy it.
.PP
.IR Createdb
is a shell script that invokes
.IR psql .
Hence, a
.IR postmaster
process must be running on the database server host before
.IR createdb 
is executed.  In addition, the 
.SM PGOPTION
and
.SM PGREALM
environment variables will be passed on to
.IR psql
and processed as described in 
.IR psql(1).
.PP
The optional argument
.IR dbname
specifies the name of the database to be created.  The name must be
unique among all Postgres databases.
.IR dbname
defaults to the value of the
.SM USER
environment variable.
.PP
.IR createdb
understands the following command-line options:
.TP 5n
.BR "-a" " system"
Specifies an authentication system
.IR "system"
to use in connecting to the 
.IR postmaster
process.  This option no longer has any effect.
.TP
.BR "-D" " dbpath"
Specifies the alternate database location for this database.
.TP
.BR "-h" " host"
Specifies the hostname of the machine on which the 
.IR postmaster
is running.  Defaults to the using local Unix domain sockets.
.TP
.BR "-p" " port"
Specifies the Internet TCP/IP port or local Unix domain socket file 
extension on which the
.IR postmaster
is listening for connections.  Defaults to 5432, or the value of the
.SM PGPORT
environment variable (if set).
.TP
.BR "-u"
Use password authentication. Prompts for username and password.
.SH EXAMPLES
.nf
# create the demo database using the postmaster on the local host, port 5432.
createdb demo
.fi
.nf
# create the demo database using the postmaster on host eden,
# port 5000.
createdb -p 5000 -h eden demo
.fi
.SH FILES
.TP 5n
\&$PGDATA/base/\fIdbname\fP
The location of the files corresponding to the database 
.IR dbname .
.SH "SEE ALSO"
create_database(l),
destroy_db(1),
initdb(1), 
psql(1), 
postmaster(1).
.SH DIAGNOSTICS
.TP 5n
.BI "Error: Failed to connect to backend (host=" "xxx" ", port=" "xxx" ")"
.IR Createdb
could not attach to the 
.IR postmaster 
process on the specified host and port.  If you see this message,
ensure that the
.IR postmaster
is running on the proper host and that you have specified the proper
port.  If your site uses an authentication system, ensure that you
have obtained the required authentication credentials.
.TP
.BI "user \*(lq" "username" "\*(rq is not in \*(lqpg_user\*(rq"
You do not have a valid entry in the relation \*(lqpg_user\*(rq and
cannot do anything with Postgres at all; contact your Postgres site
administrator.
.TP
.BI "user \*(lq" "username" "\*(rq is not allowed to create/destroy databases"
You do not have permission to create new databases; contact your Postgres
site administrator.
.TP
.IB "dbname" " already exists"
The database already exists.
.TP
.BI "database creation failed on" " dbname"
An internal error occurred in 
.IR psql
or the backend server.  Ensure that your Postgres site administrator has
properly installed Postgres and initialized the site with 
.IR initdb .
.SH NOTE
The command internally runs \fIcreate database\fP from \fP\fIpsql\fP
connected to the \fItemplate1\fP database to perform the operation.