createdb

Name

createdb  --  Create a new Postgres database 新規に Postgres データベースを作成する

Synopsis

createdb [ dbname ]
createdb [ -h host ] [ -p
port ]
      [ -D datadir ] [ -u ]
 dbname ]
  

入力

-h host

Specifies the hostname of the machine on which the postmaster is running. Defaults to using a local Unix domain socket rather than an IP connection.

postmaster が稼動しているマシンのホスト名 を 指定します。省略時には、 IP 接続ではなくローカルの Unix ドメインのソ ケット が使われます。

-p port

Specifies the Internet TCP/IP port or local Unix domain socket file extension on which the postmaster is listening for connections. The port number defaults to 5432, or the value of the PGPORT environment variable (if set).

postmaster が接続要求を監視しているイン ターネ ットの TCP/IP ポートあるいは、ローカルの Unix ドメイン ソケット ファ イル の拡張子部分を指定します。ポート番号は省略時は 5432 ですが、環境変数 PGPORT が設定されていればその値になります。

-u

Use password authentication. Prompts for username and password.

パスワード認証を使用します。 usernamepassword の入力が 要求されます。

-D datadir

Specifies the alternate database location for this database installation. This is the location of the installation system tables, not the location of this specific database, which may be different.

標準とは別の場所にデータベースを作成する場合にその場所を指定します。 これは システム表がインストールされる場所で、ここで指定するデータベースの場 所では ありません。この両者は異なる場合があります。

dbname

Specifies the name of the database to be created. The name must be unique among all Postgres databases in this installation. dbname defaults to the value of the USER environment variable.

作成するデータベースの名前を指定して下さい。データベース名はこのイン ストールにおける複数の Postgres データベース間で一意でなくてはい けません。 dbname は省略時は環境変 数 USER の値になります。

出力

   createdb will create files in the PGDATA/dbname/ data area for the new database. createdb は、 PGDATA/ dbname/ の新規データベース用データ エリアにファ イルを作成します。

Connection to database 'template1' failed. connectDB() failed: Is the postmaster running and accepting connections at 'UNIX Socket' on port 'port'? createdb: database creation failed on dbname.

createdb could not attach to the postmaster process on the specified host and port. If you see this message, ensure that the 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.

createdb は指定されたホストの指定ポート上 の postmaster プロセスに接続できませんでし た。 このメッセージが出力されたときは、指定した適切なホストの適切なポート 上で postmaster が実行されているか確認してくだ さい。 サイトで認証システムを使用している場合は、認証の通過に必要な資格を 持って いるか確認して下さい。

Connection to database 'template1' failed. FATAL 1: SetUserId: user 'username' is not in 'pg_shadow' createdb: database creation failed on dbname.

You do not have a valid entry in the relation pg_shadow and and will not be allowed to access Postgres. Contact your Postgres administrator.

pg_shadow 表に有効なエントリがないため Postgres への接続が許可されません。サイトの Postgres 管理者に連絡してください。

ERROR: user 'username' is not allowed to create/destroy databases createdb: database creation failed on dbname.

You do not have permission to create new databases. Contact your Postgres site administrator.

データベースを作成する権限がありません。サイトの Postgres 管理者に連絡してください。

ERROR: createdb: database 'dbname' already exists. createdb: database creation failed on dbname.

The database already exists.

同名のデータベースがすでに存在します。

createdb: database creation failed on dbname.

An internal error occurred in psql or in the backend server. Ensure that your site administrator has properly installed Postgresand initialized the site with initdb.

psql 、あるいはバックエンド サーバでの処 理中に内部エラーが 発生しました。サイトの管理者が適切に Postgres をインストール し、initdb でサイトを初期化したか確認して 下さい。

Note: createdb internally runs CREATE DATABASE from psql while connected to the template1 database.

createdb は内部で template1 データベースに接続し、 psql から CREATE DATABASE を実行します。

説明

createdb creates a new Postgres 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.

createdb は新規に Postgres データベースを作成します。 このコマンドを実行したユーザが作成されたデータベースのデータベース管理者 (または DBA )となり、そのユーザと Postgres のスーパーユーザだけがこのデータベースを削除できます。

createdb is a shell script that invokes psql. Hence, a postmaster process must be running on the database server host before createdb is executed. The PGOPTION and PGREALM environment variables will be passed on to psql and processed as described in psql.

createdb の実体は psql を呼び出すシェル スクリプトです。 したがって createdb が起動される前にデータベー ス サーバ ホスト上で postmaster プロセスが実行中である必要がありま す。 環境変数 PGOPTIONPGREALMpsql に渡され psql に記述されているような方法で処理されます。

使用例

To create the database demo using the postmaster on the local host, port 5432:

ローカル ホストのポート番号 5432 上の postmaster でデータベース demo を作成する:

$ createdb demo
   

To create the database demo using the postmaster on host eden, port 5000:

ホスト eden のポート番号 5000 上の postmaster でデータベース demo を作成する:

$ createdb -p 5000 -h eden demo