※This sample exam is different from those that appear in the actual OSS-DB Exam.
initdb is a command to create a new database cluster. The user who executes the command becomes the administrator user of the database, and only the administrator user can read and write the file to be created, but this is the "database" administrator user; and the OS administrator user (root) is different. The initdb command is restricted from running as the root user for security reasons.
The directory where the database cluster is created is specified by the command line argument of initdb, but if omitted, the environment variable PGDATA is used. If this directory does not exist, it will be newly created, but if you specify an existing directory, that directory must be empty. An error occurs if the directory is not empty.
For example, when creating a database cluster in / usr / local / pgsql / data, it is often that / usr / local / pgsql does not have write privileges for general users. In this case, if the data directory does not exist, it will be an error to create the data directory when initdb is executed. once mkdir with root authority, create an empty data directory, chown to the database administrator user chmod, chmod the permission to 700 and execute initdb.
You can specify the default character set when running initdb. Since this is the character set of template 1, when you create a new database with CREATE DATABASE, it defaults to the character set of the database, but you can create a database of another character set by specifying it with parameters.
Therefore, the correct answers are B and D.