When starting mysql on Centos servers with a custom data directory you might get an error similar to the following:
2014-10-15 10:23:56 17081 [Warning] Can't create test file /database/mysql/localhost.lower-test
If you tried fixing ownership and permissions.
chown -R mysql:mysql /new-path/mysql
chmod 0755 /new-path/mysql
And you do not have SELinux enabled but you still have a problem.
All you need to do is to edit /usr/lib/systemd/system/mariadb.service
ProtectSystem=full
ProtectHome=true
and undefine those variables (setting it to false won't work)
ProtectSystem=
ProtectHome=
And reload daemon
systemctl daemon-reload
After I did this it finally worked. Interesting is that this occurs only with MariaDB 10.1 Those variables are not existent for earlier versions. Recently I have found this bug:
https://jira.mariadb.org/browse/MDEV-13896
EDIT:
Since this configuration gets overwritten after a MariaDB update, I have found a permanent fix to avoid any further downtime because of this.
cp /usr/lib/systemd/system/mariadb.service /etc/systemd/system/mariadb.service
Then I made changes here instead
vi /etc/systemd/system/mariadb.service
That's it :)
If your chmod and chown settings are already correct you might need to look into selinux.
This page explains how to configure selinux for mysql:
https://blogs.oracle.com/jsmyth/entry/selinux_and_mysql