Tricky change MariaDB datadir

Trick Mariadb into not being retarded when you just want to move a data directory Copy the default dir, backup (just in case), and create mount dir

cp -rp /var/lib/mysql/ /path/to/new/data/directory
mv /var/lib/mysql/ /var/lib/mysql.old
mkdir /var/lib/mysql
chown mysql:mysql /var/lib/mysql

Test the Mount

mount –bind /media/big_raid/data/ /var/lib/mysql
/etc/init.d/mysql start

Edit fstab to mount on boot

vim /etc/fstab

add line to end of file

/path/to/new/data/directory /var/lib/mysql bind defaults,bind 0 0

then reboot to test

shutdown -r now


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.