Restore MySQL Database from FileSystem Backup

2077 Views

Always backup your MySQL database with mysqldump but if you didn’t you can restore it from file system.

If your backup include the /var/lib/mysql directory, if so then you should be able to restore the database. Each database is contained in a separate subdirectory off /var/lib/mysql, 所以寻找一个以您的数据库名称命名的,,en,WordPress或任何其他,,en,恢复它,,en,先关闭mysql服务器,,en,将backup-ed目录复制到新服务器上的相同位置,,en,然后重启mysql服务器,,en,注意,,en,使用mysqldump命令更好地执行实际的数据库转储,而不是依赖此方法,,en,所以为了未来,,en,你应该安排这样的事情,,en,从FileSystem Backup恢复MySQL数据库,,en (WordPress or any other). To restore it, shutdown the mysql server first

sudo /etc/init.d/mysql stop

Copy the backup-ed directory into the same location on your new server, then restart mysql server

sudo /etc/init.d/mysql start

Note:- that its much better to take actual database dumps using the mysqldump command than to rely on this method. so for the future, you should schedule something like this:

mysqldump -h host -u user -ppassword --databases database1 database2 > myfile.dump

 

0 Comments

Leave a Reply