Change mysql data file location on Debian

1. Stop the mysql service

service mysql stop

 2. Migrate data files (assuming the migration target is /data/mysql)

cp -R /var/lib/mysql /data
chown -R mysql:mysql /data/mysql

  3. Modify the mysql configuration file (assuming the migration target is /data/mysql)

 /etc/mysql/my.cnf

datadir = /data/mysql

 /etc/inid.d/mysql Find the directory after the datadir section and change it to the following (assuming the migration target is /data/mysql)

datadir "/data/mysql"

 4. Start the mysql service

service mysql start

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326987261&siteId=291194637