centos7 modify the default storage path MySQL5.7

YUM to install MySQL in the default installation path is / under var / lib / mysql, and sometimes the directory allocated disk space is not large, need to be migrated to the new disk directory

df  -h

Check disk space

The move to the / home directory

1. Create a data directory in the home directory as the default path

cd /home

mkdir data

 

2. Turn off MySQL

service mysqld stop

 

3. Migrate directory

mv /var/lib/mysql  /home/data/

Or cp

cp -R /var/lib/mysql /home/data/

 

4. Set the directory permissions

chown -R mysql:mysql /home/data/mysql

 

5. Modify Profile

vim /etc/my.cnf

 

6.SELINUX settings

vim /etc/selinux/config

SELINUX of the parameters can be modified to disabled:

 

7. Restart MySQL service

mysqld restart Service    # reboot

stop service mysqld stop #

service mysqld start # start

service mysqld status # view the running status

 

8. Log test

Guess you like

Origin www.cnblogs.com/xiaolongui/p/12037224.html