1 <REFENTRY ID="APP-CREATEDB">
4 <application>createdb</application>
6 <REFMISCINFO>Application</REFMISCINFO>
10 <application>createdb</application>
13 Create a new <productname>Postgres</productname> database
17 <DATE>1998-10-02</DATE>
20 createdb [ <replaceable class="parameter">dbname</replaceable> ]
21 createdb [ -h <replaceable class="parameter">host</replaceable> ] [ -p <replaceable class="parameter">port</replaceable> ]
22 [ -D <replaceable class="parameter">datadir</replaceable> ]
23 [ -u ] [ <replaceable class="parameter">dbname</replaceable> ]
26 <REFSECT2 ID="R2-APP-CREATEDB-1">
28 <DATE>1998-10-02</DATE>
38 -h <replaceable class="parameter">host</replaceable>
42 Specifies the hostname of the machine on which the
43 <application>postmaster</application>
44 is running. Defaults to using a local Unix domain socket
45 rather than an IP connection..
49 -p <replaceable class="parameter">port</replaceable>
53 Specifies the Internet TCP/IP port or local Unix domain socket file
54 extension on which the <application>postmaster</application>
55 is listening for connections. The port number defaults to 5432,
56 or the value of the <envar>PGPORT</envar>
57 environment variable (if set).
65 Use password authentication.
67 <replaceable class="parameter">username</replaceable>
68 and <replaceable class="parameter">password</replaceable>.
72 -D <replaceable class="parameter">datadir</replaceable>
76 Specifies the alternate database location for this database installation.
77 This is the location of the installation system tables, not the location
78 of this specific database, which may be different.
82 <replaceable class="parameter">dbname</replaceable>
86 Specifies the name of the database to be created. The name must be
87 unique among all <productname>Postgres</productname> databases in this installation.
88 <replaceable class="parameter">dbname</replaceable>
89 defaults to the value of the
95 <REFSECT2 ID="R2-APP-CREATEDB-2">
97 <DATE>1998-10-02</DATE>
103 <application>createdb</application> will create files in the
104 <filename><envar>PGDATA</envar>/<replaceable class="parameter">dbname</replaceable>/</filename>
105 data area for the new database.
110 Connection to database 'template1' failed.
111 connectDB() failed: Is the postmaster running and accepting connections
112 at 'UNIX Socket' on port '<replaceable class="parameter">port</replaceable>'?
113 createdb: database creation failed on <replaceable class="parameter">dbname</replaceable>.
116 <application>createdb</application> could not attach to the
117 <application>postmaster</application>
118 process on the specified host and port. If you see this message,
119 ensure that the <application>postmaster</application>
120 is running on the proper host and that you have specified the proper
121 port. If your site uses an authentication system, ensure that you
122 have obtained the required authentication credentials.
126 Connection to database 'template1' failed.
127 FATAL 1: SetUserId: user '<replaceable class="parameter">username</replaceable>' is not in 'pg_shadow'
128 createdb: database creation failed on <replaceable class="parameter">dbname</replaceable>.
131 You do not have a valid entry in the relation <literal>pg_shadow</literal>
132 and and will not be allowed to access <productname>Postgres</productname>.
133 Contact your <productname>Postgres</productname> administrator.
137 ERROR: user '<replaceable class="parameter">username</replaceable>' is not allowed to create/destroy databases
138 createdb: database creation failed on <replaceable class="parameter">dbname</replaceable>.
141 You do not have permission to create new databases.
142 Contact your <productname>Postgres</productname> site administrator.
146 ERROR: createdb: database '<replaceable class="parameter">dbname</replaceable>' already exists.
147 createdb: database creation failed on <replaceable class="parameter">dbname</replaceable>.
150 The database already exists.
154 createdb: database creation failed on <replaceable class="parameter">dbname</replaceable>.
157 An internal error occurred in <application>psql</application>
158 or in the backend server. Ensure that your site administrator has
159 properly installed <productname>Postgres</productname>and initialized the site with
160 <application>initdb</application>.
166 <application>createdb</application> internally runs
167 CREATE DATABASE from <application>psql</application>
168 while connected to the <literal>template1</literal> database.
171 <REFSECT1 ID="R1-APP-CREATEDB-1">
173 <DATE>1998-10-02</DATE>
179 <application>createdb</application> creates a new
180 <productname>Postgres</productname> database.
181 The person who executes this command becomes
182 the database administrator, or <acronym>DBA</acronym>,
183 for this database and is the only
184 person, other than the <productname>Postgres</productname> super-user,
188 <application>createdb</application> is a shell script that invokes
189 <application>psql</application>.
190 Hence, a <application>postmaster</application>
191 process must be running on the database server host before
192 <application>createdb</application>
194 <envar>PGOPTION</envar>
196 <envar>PGREALM</envar>
197 environment variables will be passed on to
198 <application>psql</application>
199 and processed as described in <xref linkend="app-psql" endterm="psql-ref">.
201 <REFSECT1 ID="R1-APP-CREATEDB-2">
203 <DATE>1998-10-02</DATE>
209 To create the database <literal>demo</literal>
210 using the postmaster on the local host, port 5432:
215 To create the database <literal>demo</literal>
216 using the postmaster on host eden, port 5000:
218 createdb -p 5000 -h eden demo