Usage Guidelines

Background

During installation, you are advised to use the -D parameter to invoke gs_initdb to initialize a database. If a database needs to be initialized to rectify a fault, run gs_initdb.

  • Although gs_initdb attempts to create the corresponding data directory, it may not have the permission to do so. Because in most cases, the parent directory is owned by user root. To create a data directory, create an empty data directory as user root first and transfer the ownership of this directory to the database user using chown.
  • gs_initdb is used to set the template1 database and the settings become the default settings of other databases.
  • gs_initdb initializes the default locale and character set encoding of a database. The character set encoding, character encoding order (LC_COLLATE), and character set classes (LC_CTYPE, for example, uppercase letter, lowercase letter, or digit) can be set separately for a database when it is created.

Procedure

  1. Log in to any host of the openGauss database as the OS user omm.

  2. Plan the database directory.

    1. Switch to the root user.

      su - root
      
    2. Enter your username and password as prompted.

  3. Go to the /opt/gaussdb directory and create the data1 directory where the DN resides.

    cd /opt/gaussdb
    mkdir data1
    
    1. Allocate the ownership of the data1 directory to user omm, and dbgrp is the user group to whom user omm belongs to.

      chown omm:dbgrp data1
      
    2. Log out as user root.

      exit
      
  4. Run the gs_initdb command to initialize the database and set password as prompted.

    gs_initdb /opt/gaussdb/data1 --nodename dn1
    Enter new system admin password:[PASSWORD]
    Enter it again:[PASSWORD]
    

    gs_initdb syntax:

    gs_initdb [OPTION]... [DATADIR]
    

    For parameters about OPTION, see Command Reference.

Feedback
编组 3备份
    openGauss 2025-06-26 22:43:36
    cancel