简体   繁体   English

进行MySQL大数据库导出的最佳方法

[英]Best way to do a MySQL large database export

I've usually use mysqldump to export a database. 我通常使用mysqldump导出数据库。 However, when the database is really large, it seems much faster and less intensive to just gzip the database files directly without involving the MySQL deamon and copying that to the other database. 但是,当数据库很大时,直接gzip数据库文件而不涉及MySQL守护进程并将其复制到另一个数据库似乎更快,更省力。

eg: 例如:

tar -czvf {db_name}.sql.tgz /var/lib/mysql/{db_name}

Is this a good method of doing this? 这是个好方法吗? What are the (dis)advantages? 有哪些(缺点)优势?

I also read another post here that mentioned: 我还在这里阅读了另一篇提到的文章:

rsync /var/lib/mysql/ ...

Would it be a good option to just use rsync to keep a backup db in sync with the development db? 仅使用rsync来使备份数据库与开发数据库保持同步是一个好选择吗?

重新提到您提到的第一种方法:我认为mySQL的官方mysqlhotcopy使用了这种方法,因此不可能完全错误。

I've used rsync just fine with moving files around and using them on other boxes. 我使用rsync可以很好地移动文件并在其他盒子上使用它们。 I've never done it with the MYSQL running live, but i've restored from the files in /var/lib/mysql before with no problems. 我从未在MYSQL实时运行的情况下做到这一点,但是我之前从未从/ var / lib / mysql中的文件中恢复过它。 It's a good way to "copy" over databases for your "development" box. 这是在“开发”框中“复制”数据库的好方法。 I suggest shutting down mysql, moving the files over then starting it back up again. 我建议关闭mysql,移走文件,然后重新启动它。 That is how I've done it when necessary. 这就是我在必要时所做的方式。

myqldump gives you nice neat SQL code though, good if you ever need to "tweak" something with sed along the way. myqldump可以为您提供漂亮的整洁的SQL代码,如果您在一路上需要对sed进行“调整”,那将是一个很好的选择。

I'd have no worries about using rsync though. 我不会担心使用rsync。 I use it for many purposes including pushing code updates out to client machines. 我将其用于许多目的,包括将代码更新推送到客户端计算机。

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

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