Realization Method of Switching Data Storage Directory in Mysql

  • 2021-08-31 09:30:23
  • OfStack

Realization Method of Switching Data Storage Directory in Mysql

Today, I encountered in my work that mysql and the partition space where the storage is located have been used up, which leads to the failure of mysql to start normally, so I can only migrate the data storage directory.

1. Transfer the existing data storage directory to another storage space. When transferring today, the data file of 50G was copied for more than 30 minutes, which was somewhat slow.

2. Modify the my. cf configuration file

Modify the storage directory

[mysqld]


datadir=/home/mysql

socket=/home/mysql/mysql.sock

[mysql_safe]


pid-file=/home/mysql/mysqld.pid

Add

[mysql]


socket=/home/mysql/mysql.sock

3, 1 must pay attention to modify, data storage directory permissions, especially appear

mysql_safe pid home/mysql/mysqld.pid* ended

Thank you for reading, hope to help everyone, thank you for your support to this site!


Related articles: