Sample Exam Questions

From the objective of OSS-DB Exam Silver
S2.1 Installation

Sample Question

2.38

Choose the three most appropriate descriptions for the initdb command.

 
  1. It should be run as the user who will be the database administrator.

  2. On Linux, since root is the system administrator, initdb should also be run as root.

  3. A database cluster is created and it becomes possible to connect to the database using, for example, psql.

  4. The directory in which the database cluster will be created can be created in advance, but it must be empty.

  5. Three databases named template0, template1, and postgres are created.

※This sample exam is different from those that appear in the actual OSS-DB Exam.
2024/05/08

Answer and Explanation

initdb is the command for creating a new database cluster, which performs the creation of the directory in which to store the databases, creation of the shared catalog tables, the creation of the template databases template0 and template1, and the creation of the database named postgres.

Because the database server process must be able to access the database files, initdb must be run with the privileges of the database administrator user. However, because the Linux root user cannot run database processes, the database file cannot be owned by root, and initdb cannot be run as root.

initdb has the ability to create a new directory for the database cluster, but on Linux and so on, you might not have write permission for that directory. To work around this problem, it is common to create a database cluster directory with root privileges, then use the chown command to change the owner of the directory to the database administrator user, and then run initdb. However, the contents of this directory must be empty (If it is not empty, an error occurs when initdb runs.).

initdb only creates the directory and database files for the database cluster and does not start the server processes for the database. Therefore, running this command is not enough to enable the connection to the database. You must run a separate command to start the server process, or configure the server to start automatically at system startup.

So the correct answers are A, D, and E.