Cannot write pid file

MariaDB seems to have this issue and can't start as shown in /var/log/mariadb/mariadb.log

12020-02-19 15:18:49 0 [ERROR] mysqld: Can't create/write to file '/var/run/mariadb/mariadb.pid' (Errcode: 2 "No such file or directory")

I was able to fix one instance of this issue by doing:

1sudo mkdir /var/run/mariadb
2sudo chown mysql.mysql /var/run/mariadb

Then afterwards, starting the mariadb service went fine.

Some possible solutions in case my solution doesn't work https://stackoverflow.com/questions/15408643/cant-connect-to-mysql-server-cant-create-write-the-pid-file