After Installing Nginx Amplify on Ubuntu Server 20.04 on the Raspberry Pi, you need to make some adjustments in order for Amplify to pick up and monitor Maria Database / Mysql. This tutorial assumes you have already installed Amplify and set up MariaDB for Amplify, enabling the Amplify plugin and creating a MariaDb Password for Amplify. If you haven’t done so already, you can follow this excellent guide to do so.

Once Amplify is all set up and configured on your Pi, there are a few extra steps to take in order to get your Amplify to recognize MariaDb.

1) Find the MariaDB service file in your terminal

systemctl status mariadb

returns:

● mariadb.service - MariaDB 10.10.5 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)

2) Check your symlinks

Running

readlink -f /usr/sbin/mysqld 

shows you that /usr/sbin/mysqld is a symlink pointing to /usr/sbin/mariadbd

3) “Cat” the service file and inspect it’s contents:

cat /lib/systemd/system/mariadb.service

Find the line that starts with ExecStart=

ExecStart=/usr/sbin/mariadbd $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION

This is the line that we need to replace, but we can’t replace it directly in this file or else it will be overwritten during an update to MariaDB / Mysql. Therefore, to change this line permanently, we have to create a new file in a new directory.

4) Create the new directory

sudo mkdir - p /etc/systemd/system/mariadb.service.d

5) Now lets create the configuration file.

This file will override the ExecStart= line in /lib/systemd/system/mariadb.service

sudo nano /etc/systemd/system/mariadb.service.d/nginx-amplify.conf

Copy and paste all of the following code content into that file

# THIS FILE IS MEANT TO CHANGE THE SYMLINK PATH OF
# EXECSTART SO NGINX AMPLIFY PICKS UP MYSQL/MARIADB:
#
# It's not recommended to modify the
# file /lib/systemd/system/mariadb.service in-place,
# because it will be overwritten during package upgrades.
# If you want to customize that file, the best way is to create a
# file "/etc/systemd/system/mariadb.service.d/foo.conf",
# which doesn't need to include ".include" call and which will
# be parsed after the file mariadb.service itself is parsed.
#
# For more info about custom unit files, see systemd.unit(5) or
# https://mariadb.com/kb/en/mariadb/systemd/

[Service]

# Clear the original "ExecStart=" settings:
# To clear the original ExecStart in
# the /lib/systemd/system/mariadb.service file, you must first
# enter an "ExecStart=" here with an empty value before adding
# your newly created ExecStart for Amplify.
# https://stackoverflow.com/questions/68817332/why-use-execstart-with-no-value-before-another-execstart-new-value-in-a-syst
ExecStart=

# Set Nginx Amplify "ExecStart=" settings:
# For Nginx Amplify to pick up the mysql/mariadb settings, you
# must change the "ExecStart=" value to the mysql symlink path so
# that Amplify Agent picks it up.
ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION

Save the file and exit nano. This file you just created, has changed the ExecStart= line, and will preserve those settings across updates to MariaDb / Mysql, to keep Amplify working with MariaDb.

6) Finally, run the following commands to have the changes reflect:

sudo systemctl daemon-reload
sudo systemctl restart mariadb
sudo systemctl restart amplify-agent

7) Now log into Amplify and check your Mysql settings.

Log into amplify.nginx.com with your username and password. You should have Mysql data that starts showing up. Note: It may take a few minutes for your server to update Amplify with it’s newly created Mysql ExecStart Settings, so If Mysql doesn’t appear in Amplify right away, wait a few minutes and log back into Amplify.

8) DONATE! If this tutorial it worked for you (which it should have), you could spread the love back and donate some change to my paypal, bitcoin address, or altcoin addresses.

PAYPAL:

BITCOIN (BTC) ADDRESS:

bc1qxsqy0nl8f2rqsgpzzr8eh3c67vz7kjr2djyku4

BITCOIN CASH (BCH) ADDRESS:

qzdkv8sz8zf57urafd8urhg7jdej6u892v3z088nvr

ETHEREUM (ETH) ADDRESS:

0x8C33CD44a083D605DBb65Ba4eC201f30Af88705c

ZCASH (ZEC) ADDRESS:

t1dxu9KN1pSYNoMNxYMzCNhcHJhGZmwPW9n

MONERO (XMR) ADDRESS:

4A2p4k6vSGviUxoZvwQkAX8VBQE6tQncmZUS5mZ8YS9cZ2BQ4cc2CZXdMVg4vtFoxh3XrXQECWm95Gq2FpyRtvFz2yNZuYy

9) FINISHED! You have now properly set up Nginx Amplify to properly monitor MariaDB/Mysql on your Raspberry Pi!