Some times when MariaDB installed first time, it runs ok but after System reboot, its start creating problems i.e. MariaDB service stuck at Activating state.
if you try to start it, its seems keep waiting in staring state and when check status using command
systemctl status mariadb.service
its shows status like
Active: activating (start)
in journalctl -xe output you see errors like AVC apparmor=”DENIED”
Reason for this problem is that, you probably have MySQL installed beforehand. Mean first this server had MySQL server installed and upgraded it to MariaDB server. It is a known bug: MySQL installs an AppArmor profile, and the MariaDB package fails to properly uninstall it (see details on Launchpad).
Solution:
Use these commands to solve the problem (adapted from the bug mentioned above):
sudo systemctl stop mariadb
echo “/usr/sbin/mysqld { }” | sudo tee /etc/apparmor.d/usr.sbin.mysqld
sudo apparmor_parser -v -R /etc/apparmor.d/usr.sbin.mysqld
This should display output like this Removal succeeded for “/usr/sbin/mysqld”.
Then, very important step is:
sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/usr.sbin.mysqld
Without above command, some AppArmor profile comes back after reboot (not sure from where), which prevents MariaDB from loading at all (unable to load libaio).
Now you can then start MariaDB with
sudo systemctl start mariadb
Hopefully now it will work ok. check status by
sudo systemctl status mariadb
Background Reason
If you previously had MySQL installed, it activated an AppArmor profile which is incompatible with MariaDB.
apt-get remove –purge only removes the profile, but does not deactivate/unload it. Only manually unloading it lets MariaDB work unhindered by AppArmor.
Ref: Ale ServerFault