mariadb server won't start after moving the data directory

Hi. Today I attempted to move the mariadb data directory using the procedure outlined here: https://www.digitalocean.com/community/tutorials/how-to-change-a-mysql-data-directory-to-a-new-location-on-centos-7

I was not able to restart the server after moving the data directory and pointing to the correct new path in my.cnf. However, if I simply comment out the datadir instruction in my.cnf things work fine using the standard data directory (/var/lib/mysql). If I try, this happens (output of 'systemctl status mariadb.service'):

-----------------------------
May 19 11:40:44 crummyworld3 mysqld[14010]: 2017-05-19 11:40:44 139833240783104 [ERROR] Plugin 'InnoDB' init function returned error.
May 19 11:40:44 crummyworld3 mysqld[14010]: 2017-05-19 11:40:44 139833240783104 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
May 19 11:40:44 crummyworld3 mysqld[14010]: 2017-05-19 11:40:44 139833240783104 [Note] Plugin 'FEEDBACK' is disabled.
May 19 11:40:44 crummyworld3 mysqld[14010]: 2017-05-19 11:40:44 139833240783104 [ERROR] Could not open mysql.plugin table. Some plugins may be not loaded
May 19 11:40:44 crummyworld3 mysqld[14010]: 2017-05-19 11:40:44 139833240783104 [ERROR] Unknown/unsupported storage engine: InnoDB
May 19 11:40:44 crummyworld3 mysqld[14010]: 2017-05-19 11:40:44 139833240783104 [ERROR] Aborting
May 19 11:40:44 crummyworld3 systemd[1]: mariadb.service: main process exited, code=exited, status=1/FAILURE
May 19 11:40:44 crummyworld3 systemd[1]: Failed to start MariaDB database server.
May 19 11:40:44 crummyworld3 systemd[1]: Unit mariadb.service entered failed state.
May 19 11:40:44 crummyworld3 systemd[1]: mariadb.service failed.
---------------------------

Is there something missing in the instructions?

Answer Answered by kanika satija in this comment.

When we start mariadb service after changing the default mariadb data directory then there is an error in starting services due to change in SE linux policy. Therefore, below changes needs to be done in SE linux policy

1)	semanage fcontext -a -t mysqld_db_t "/mnt/volume-nyc1-01/mysql(/.*)?"
2)	restorecon -Rv /mnt/volume-nyc1-01/mysql
3)	Also add below section in mariadb configuration “/etc/my.cnf file”
        [client]
        socket=/mnt/volume-nyc1-01/mysql/mysql.sock
4)	sudo systemctl start mariadb
5)     mysql -u root -p
6)     select @@datadir;
7)     In output new data directory "/mnt/volume-nyc1-01/mysql/" should be visible
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.