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
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It only takes a minute to sign up.
Sign up to join this communityIf 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
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 :)
When running on CentOS 7, check out the systemd unit files which may prevent writing to / protect non-MySQL directories like /home
.
The unit files lives in /usr/lib/systemd/system/mariadb.service
.