1

This is CentOS 8.1 and MariaDB 10.3 database server.

I have followed the directions I've seen in several places to relocate the datadir from the default of /var/lib/mysql to /home/mysql. /home is the RAID.

I've made the change in /etc/my.cnf putting this before the !include stuff, but it appears to be still pointing to /var/lib/mysql.

When I have done this, mysql complains and it won't bring let my run the mysql command.

I have looked in /etc/my.cnf.d and see the default is still there in mariadb-server.cnf.

I see this message in the log and wasn't sure if this was related or not?

Mar 11 11:58:44 myserver systemd[1]: Starting MariaDB 10.3 database server...

Mar 11 11:58:44 myserver mysql-prepare-db-dir[6349]: **Database MariaDB is probably initialized in /var/lib/mysql already, nothing is done.**

Mar 11 11:58:44 myserver mysql-prepare-db-dir[6349]: **If this is not the case, make sure the /var/lib/mysql is empty before running mysql-prepare-db-dir.**

I have tried running mysql-prepare-db-dir, but the same messages appear in the logs.

  • Check the protection mechanism -- selinix? – Rick James Mar 14 at 19:42
  • What is the datadir in /etc/my.cnf? – Nasir Riley Mar 15 at 2:16
1

Make sure you put datadir in a [mysqld] section, and be aware that when configs are loaded, the LAST statement wins, not the first as you seem to be implying by putting it before the !includes. Do a grep -R for datadir in your MySQL configs and check where it is being set, if anywhere.

In reality, you are going about it the wrong way, though. It is a much better practice to mount --bind /home/mysql /var/lib/mysql. And make sure you restorecon -rv /var/lib/mysql to get your SELinux labels correct.

| improve this answer | |

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