MariaDB Datadir – How to Change Datadir for MariaDB

mariadbMySQL

I have installed MariaDB and changed datadir to /tank/mysql and that was working.

After that I had to reinstall MariaDB and I was using:

apt -y remove --purge mariadb-server
apt -y install mariadb-server

and that went ok.

Problem is now that datadir is not changed.

File in which I have changed is same as it was before:
/etc/mysql/mariadb.conf.d/60-mariadb.cnf

Code:

[mysqld]
datadir=/tank/mysql

MariaDB is pointing to /var/lib/mysql

I know best solution would be to reinstall whole ubuntu server but that it not the option now.

If there is anything else I can wrote to improve my question, please suggest.

No file contains "/var/lib/mysql" in /etc/mysql folder.

I had already this problem after reinstalling on other server and I could not solve it so on the end I have reinstalled whole server.

Information:

OS: Ubuntu server 16.04

MariaDB version: 10.2.15

Best Answer

On Debian 9 I solved by running:

mysql_install_db --datadir=YOURDATADIR

then changing datadir option in

/etc/mysql/mariadb.conf.d/50-server.cnf

(or whatever file containing datadir option) according to YOURDATADIR above and restarting mariadb.service