show global variables like '%datadir%';
systemctl stop mysqld
mkdir -p /package/mysqldata
cp -a -r /var/lib/mysql/* /package/mysqldata
chown -R mysql:mysql /package/mysqldata
mv /var/lib/mysql /var/lib/mysqlbak
ln -s /package/mysqldata /var/lib/mysql
chown -h mysql:mysql /var/lib/mysql
systemctl start mysqld
vi /etc/my.cnf
datadir=/package/mysqldata
socket=/package/mysqldata/mysql.sock
mysqld --defaults-file=/etc/my.cnf --initialize --user=mysql
systemctl start mysqld
systemctl status mysqld.service
ln -s /package/mysqldata/mysql.sock /var/lib/mysql/mysql.sock
mysql -uroot -p