mysql modified the storage path and failed authorization when restarting

Stop mysql

Modify the mysql configuration file my.cnf

Change the mysql storage location to the /data/mysql_data directory:

 datadir=/data/mysql/mysql_data/
 socket=/data/mysql/mysql_data/mysql.sock

The default path of mysql is /var/lib/mysql/

To prevent data loss, copy all files in the mysql directory to the new directory mysql_data.

cp /var/lib/mysql/** /data/mysql/mysql_data

directory authorization

chown -R mysql:mysql /data/mysql/mysql_data    
restorecon -FRv /var/lib
setenforce 0

Restart mysql

service mysqld restart 

Guess you like

Origin blog.csdn.net/csl12919/article/details/132335558