B.2 Configuring MariaDB

When MariaDB is initially installed, it is not configured with an administrator password, nor is it configured to start automatically. To set up the MariaDB database server for use with CIS, perform the following:

  1. In a terminal window, become the root user.

  2. To start the database server, run the following command:

    systemctl restart mysql.service

  3. To enable the database server, run the following command:

    systemctl enable mysql.service

  4. To verify the database server has started, run the following command:

    systemctl status mysql.service

  5. To set the root password and enable root access from remote machines, run the following command:

    mysql_secure_installation

    1. It prompts for current password for root user, press 'Enter' to continue.

    2. It prompts to Set root password?, enter 'y' to continue and then enter password.

      The password is updated successfully.

    3. It prompts to Remove anonymous users?, press 'Enter' to continue with the default configuration.

    4. It prompts to Disallow root login remotely?, enter 'n' to continue.

    5. It prompts to Remove test database and access to it?, press 'Enter' to continue with the default configuration.

    6. It prompts to Reload privilege tables now?, enter 'y' to continue.

  6. Login to MariaDB.

    mysql -u root -p

    It prompts for password.

  7. To grant permissions for the superuser account, run the following commands:

    > GRANT ALL PRIVILEGES ON *.* TO '<username>'@'%' IDENTIFIED BY '<password>';

    > FLUSH PRIVILEGES;

    For example:

    GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password';

  8. To enable the firewall, run the following command:

    yast2 firewall

    The Firewall Configuration: Start-Up window is displayed.

  9. In the left menu, click Allowed Services and then click Advanced option.

    The Additional Allowed Ports window is displayed.

  10. Add 3306 port under the TCP Ports and then click OK.

  11. Click Next and Finish.