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

3 Answers 3


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

  • And what if selinux is disabled and this still happens?
    – Luka
    Mar 7, 2018 at 23:54
  • If selinux is disabled. Then you need to check your chmod/chown settings. Another thing you can check is if your harddrive is full. Also check out Uwe's answer above. It could be helpful in your case.
    – Haluk
    Mar 8, 2018 at 12:48
  • None of the above. The new MariaDB 10.1 adds some weird protection to Systemd service file. I'm gonna write a FIX i discovered as an answer.
    – Luka
    Mar 8, 2018 at 13:16

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


and undefine those variables (setting it to false won't work)


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:



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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.