Title: Configure MariaDB
Course: Establish and maintain an LMS > Section: 03 - Configure MariaDB - New System

Click on the “Start Menu”, search for “notepad”, right click the icon and click on “Run as Administrator”

Click “Yes” on the UAC window.

Click in “File” and then “Open”

Navigate to c:\Program Files\MariaDB 10.3\data (the number 10.4 might be different depending on the version you installed)

Select “All files” in the dropdown menu.

Where you see “UTF-8” in the image below, change to ANSI

Select the file “my” where you can see a cog in the icon and “Configuration settings” on the right.

Click Open.

The image below shows the typical configuration.

You can copy the text below and replace the original:

[mysqld]
datadir=C:/Program Files/MariaDB 10.3/data
port=3306
innodb_buffer_pool_size=1012M
innodb_file_format = Barracuda
innodb_file_per_table = 1
innodb_large_prefix = 1
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
skip-character-set-client-handshake

[client]
port=3306
plugin-dir=C:/Program Files/MariaDB 10.3/lib/plugin
default-character-set = utf8mb4

[mysql]
default-character-set = utf8mb4

Your file should look exactly like the one below. Also note that the paths in the file should match the paths in your computer. It’s likely that MariaDB will be installed in a different folder rather than “MariaDB 10.3” like in the text above. Please adjust accordingly.

Click on File and Save

And then in File and Exit

Now you can click on the Start Menu and the power icon. Then select restart.

Your database is now installed and running every time you restart your computer.

Create a new Database for Moodle

Click on the “Start Menu”, search for “MySQL”. You should see a software called “MySQL Client (MariaDB 10.x (x64)”. Click on it.

Enter the password you set for the root access of the Database in the previous chapter.

If you typed the correct password, you should see the screen below.

In this software (we call it a terminal) you will be typing MySQL commands. Those are commands meant to communicate and change the database. Remember that all commands end with a semicolon “;” which is the character MySQL understands as the end of a line.

Now type:

SHOW DATABASES;

And press enter. (don’t forget the semicolon at the end of the command)

You should see a result similar to the one below:

Now let’s create the database, type:

CREATE DATABASE moodle DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

And press Enter. One more time, the software should return the message “Query OK, 1 row affected”

Now let’s create a new user called “moodleuser” and grant it access to the database using the code below

GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON moodle.* TO moodleuser@localhost IDENTIFIED BY 'yourpassword';

Please notice the part in red in the comment above. That will be the password that Moodle will use to communicate to the Database. It is very important that you create a strong password for the database.

You can think of a strong password yourself, or you can use the website https://passwordsgenerator.net/ to generate a random password.

Navigate to the website, uncheck “Include Symbols” and click in “Generate Password”.

Your password will appear in the “Your New Password” field.

Copy this password to the clipboard by selecting and pressing CTRL-C or by selecting it, clicking on the text with the right mouse button and clicking in “copy”.

Now enter the command above changing the word “your password” to the password you created.

Note that the password is still enclosed between Apostrophes -> ‘

Once you press enter on your keyboard, you will see the message “Query OK, 0 rows affected.”

You can now type quit and press enter.

Concluding remarks

It is very important that you write down the Database password or copy it to a text file using the notepad or other text tool. You will need it in the next guide.