mysqlhotcopy
Use mysqlhotcopy, the database engine can only back up MYISAM
installation
yum install -y perl perl-DBI perl-DBD-MySQL
We need to create a special account to back up
grant select,reload,lock tables on *.* to 'hotcopyer'@'localhost' identified by '123456';
Common options and examples
mysqlhotcopy -u ... -p password -S /tmp/...sock 库名(多库名空格隔开) 备份的目录
# -u -p 后面必须有空格 可以加一个--flushlog 刷新2进制文件
mysqlhotcopy -u ... -p ... -S ... 原库名 新库名 #会在mysql datadir下产生一个新库目录
- -q Quiet mode
- --flushlog refresh the binary log
Data recovery
- Close the database
mysqladmin -uroot -p -S /mysql/data/mysql.sock shutdown
- Delete or remove datadir
The original data is removed, and then directly to the data file backup decompression and put back under datadir, and modify their user and group mysql
cp -a 备份文件 datadir
chown mysql.mysql datadir
- And then start the database
service mysqld start