简体   繁体   English

MySQL备份/恢复问题

[英]MySQL Backup/Restore Issue

I need to move a MySQL DB to a new location. 我需要将MySQL数据库移动到新位置。 The DB is only 200MB in size according to workbench, but there are some tables with millions of rows which report indexes and data length of several GB. 根据工作台,DB的大小只有200MB,但有一些表有数百万行报告索引和数据长度为几GB。 As a result the EXPORT is 15GB in size, and it takes many hours to export the DB, and copy it to new location, and many more again to import it. 因此,EXPORT的大小为15GB,导出数据库需要花费数小时,并将其复制到新位置,再次导入数据库。 During this process the website needs to be offline so that the database is not changed. 在此过程中,网站需要脱机,以便不更改数据库。 First attempt too over 36 hours, and the import failed. 第一次尝试超过36小时,导入失败。 This is simply too long, is there any better/quicker way to do this then the horrible import/export? 这太长了,有没有更好/更快的方法来做这个可怕的导入/导出? I am used to working with MSSQL which is very quick to do this sort of thing, take db offline, copy the file to new location, mount DB, done. 我习惯使用MSSQL,它可以非常快速地执行此类操作,使db脱机,将文件复制到新位置,装入DB,完成。 it takes minutes and is so easy. 这需要几分钟而且很容易。 Never understood why MySQL makes this so hard. 从来没有理解为什么MySQL如此努力。

Percona XtraBackup is a useful tool, if you have InnoDB tables innobackupex will help to make a hot-backup and restore. Percona XtraBackup是一个有用的工具,如果你有InnoDB表, innobackupex将有助于进行热备份和恢复。

Also configuring InnoDB File-Per-Table the backup will be like MyISAM tables. 另外,配置InnoDB File-Per-Table的备份将类似于MyISAM表。

If you have MyISAM tables the process is: 如果您有MyISAM表,则该过程为:

  1. Stop server origin server. 停止服务器原始服务器
  2. Copy (and compress) your database folder in a secure place, for example: /var/lib/mysql/your_database . 数据库文件夹复制(并压缩)到安全的位置,例如: /var/lib/mysql/your_database
  3. Restore the files in the same place in destination server after stop MySQL server. 停止MySQL服务器后,恢复目标服务器中相同位置的文件。
  4. Start destination server. 启动目标服务器。

Both servers must have a minimal difference in version because MyISAM have their own format version. 两个服务器的版本差异最小,因为MyISAM有自己的格式版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM