nativeInstallerphplist

Create a new MariaDB database and user

Before running the commands shown on this page, you should load the Bitnami stack environment by executing the installdir/use_APPNAME script (Linux and MacOS) or by clicking the shortcut in the Start Menu under “Start -> Bitnami APPNAME Stack -> Application console” (Windows). On OS X VMs, the installation directory is /opt/bitnami and OS X VM users can click the “Open Terminal” button to run commands. Learn more about the Bitnami stack environment and about OS X VMs.

NOTE: We are in the process of modifying the configuration for many Bitnami stacks. On account of these changes, the file paths and commands stated in this guide may change depending on whether your Bitnami stack uses MySQL or MariaDB.

Linux and macOS native installer users can identify which database server is used in the stack by running the command below:

 $ test -d installdir/mariadb && echo "MariaDB" || echo "MySQL"

Windows native installer users can identify which database server is used in the stack by checking for the presence of the installdir/mariadb directory. If present, the installer uses MariaDB and if not, it uses MySQL.

Depending on which database server (MySQL or MariaDB) is used by the installation, use the appropriate guides in our documentation for database-related operations.

Log in to the database server using the MariaDB client and the correct credentials. Then, follow the steps below to create a new database and user for your applications.

The commands below create both a local user and a remote user. The local user can be used only for local connections (connections originating from the same host), while the remote user can be used for external connections (connections originating outside the host).

  • Create a new database:

      MariaDB> create database DATABASE_NAME;
    
  • Create a new user (only with local access) and grant privileges to this user on the new database:

      MariaDB> grant all privileges on DATABASE_NAME.* TO 'USER_NAME'@'localhost' identified by 'PASSWORD';
    
  • Create a new user (with remote access) and grant privileges to this user on the new database:

      MariaDB> grant all privileges on DATABASE_NAME.* TO 'USER_NAME'@'%' identified by 'PASSWORD';
    
  • After modifying the MariaDB grant tables, execute the following command in order to apply the changes:

      MariaDB> flush privileges;
    

Some applications require specific privileges in the database. Check the MariaDB official documentation for getting, installing, and upgrading MariaDB.

Last modification July 26, 2021