Centos changes the data storage location of mysql
1. Change the data storage location of mysql (Centos)
(1) Turn off mysql
service mysqld stop
(2) Change/etc/my. cnf content
datadir=/newpath/mysql
(3) Restart mysql
service mysqld start
Generally, this step is enough. If not, try the following steps.
2. Change The selinux of the new data storage location
Semanage fcontext-a-t mysqld_db_t "/newpath/mysql (/.*)? "// Set The selinux attribute restorecon-Rv/newpath/mysql of the mysql directory to take effect
3. Change The selinux of the hard disk in NTF format
If the data is stored in the new NTF hard disk, set the selinux value of the root directory (mount point) of the NTF hard disk to system_u: object_r: default_t: s0.
semanage fcontext -a -t default_t /newpath
Restorecon-v/newpath // only change selinux in the root directory
* Note: Changing the selinux attribute of the root directory may overwrite the results in the first 2nd. If you need to re-run the commands in the Second 2nd.