# Mariadb 

First we have to install the package. This is done by running the following command:

```bash
$ sudo apt install mariadb-server
```

Now the raspberry pi will download the package and install it. After the installation is done, we have to secure the installation. This is done by running the following command:

```bash
$ sudo mysql_secure_installation
```

This will ask you a couple of questions. The first question is if you want to set a password for the root user. We chose not to because we are the only ones that have access to the raspberry pi. The second question is if you want to remove the anonymous user. We chose to remove the anonymous user. The third question is if you want to disallow root login remotely. We chose NOT to disallow root login remotely, otherwise we wouldn't be able to login to the database remotely anymore. The fourth question is if you want to remove the test database. We chose yes because we made our own database. The fifth question is if you want to reload the privilege tables now. We chose yes, because we want to apply the changes we made.

Now the installation is done and the database is secured. Now we can start using the database.

# Create a database

First we have to login to the database. This is done by running the following command:

```bash
$ sudo mysql -u root
```

Now we are logged in to the database. We have created our database by using the forward engineer function of MySQL workbench and then exporting the sql file to the raspberry pi.

# Create a user

We have to create a user for the database. This is done by running the following command:

```sql
GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;
```

Replace username with the username you want to use and password with the password you want to use. This will create a user with all privileges on all databases. If you want to create a user with less privileges you can change the ALL PRIVILEGES to the privileges you want to give the user. We chose to give the user all privileges to make it easy for us to use the database.

**Written by Sietse**