mysql 恢复另一台服务器上的文件

发布于 2024-08-02 05:46:42 字数 201 浏览 6 评论 0原文

我在与生产数据库不同的远程服务器上有一个测试数据库。每隔一段时间,我想通过将生产数据库的副本上传到测试数据库来尝试和测试。不幸的是,备份文件现在有一半大小,我无法通过 FTP 或 SSH 传输它。有没有一种简单的方法可以在服务器之间使用 mysql 恢复命令?另外,还有另一种方法可以移动我没有考虑的大文件吗?半场演出似乎并没有那么大,我想人们经常会遇到这个问题。

谢谢!

I have a test database on a separate remote server than my production DB. Every once in awhile, I want to try and test things by uploading a copy of my production DB to my testing DB. Unfortunately, the backup file is now half a gig and I'm having trouble transferring it via FTP or SSH. Is there an easy way that I can use the mysql restore command between servers? Also, is there another way to move over large files that I'm not considering? Half a gig doesn't seem that big, I would imagine that people run into this issue frequently.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

山有枢 2024-08-09 05:46:42

服务器之间可以互相访问吗?

如果是这样,您可以将数据从一个数据库通过管道传输到另一个数据库,而无需使用文件。

例如:mysqldump [选项] | mysql -h 测试 -u 用户名 -ppasswd

Are the servers accessible to each other?

If so, you can just pipe the data from one db to another without using a file.

ex: mysqldump [options] | mysql -h test -u username -ppasswd

来世叙缘 2024-08-09 05:46:42

0.请考虑您是否确实需要生产数据(特别是如果它包含一些敏感信息)

1.最简单的解决方案是在源服务器上压缩备份(通常是gzip),通过网络传输,然后在目标服务器上解压缩。

http://www .techiecorner.com/44/how-to-backup-mysql-database-in-command-line-with-compression/

2.如果您不需要生产数据的精确副本(例如您不需要不需要一些应用程序日志、错误和其他一些技术内容)您可以考虑在源服务器上创建备份并恢复到不同的数据库名称,删除所有不必要的数据,然后进行您将使用的备份。

3.在开发环境中的参考服务器上恢复一次完整备份,然后仅复制事务日志(以在参考服务器上重播它们)。根据使用模式,事务日志可能会占用比整个数据库少得多的空间。

0.Please consider whether you really need production data (especially if it contains some sensitive information)

1.The simplest solution is to compress the backup on the source server (usually gzip), transfer it across the wire, then decompress on the target server.

http://www.techiecorner.com/44/how-to-backup-mysql-database-in-command-line-with-compression/

2.If you don't need the exact replica of production data (e.g. you don't need some application logs, errors, some other technical stuff) you can consider creating a backup and restore on a source server to a different DB name, delete all unnecessary data and THEN take a backup that you will use.

3.Restore full backup once on your reference server in your Dev environment and then copy transaction logs only (to replay them on the reference server). Depending on the usage pattern transaction logs may take a lot less space as the whole database.

荆棘i 2024-08-09 05:46:42

Mysql 允许您连接到远程数据库服务器来运行 sql 命令。使用此功能,我们可以通过管道传输 mysqldump 的输出,并要求 mysql 连接到远程数据库服务器以填充新数据库。

mysqldump -u root -p rootpass SalesDb | mysql --host=185.32.31.96 -C SalesDb 

Mysql allows you to connect to a remote database server to run sql commands. Using this feature, we can pipe the output from mysqldump and ask mysql to connect to the remote database server to populate the new database.

mysqldump -u root -p rootpass SalesDb | mysql --host=185.32.31.96 -C SalesDb 
櫻之舞 2024-08-09 05:46:42

使用高效的传输方法,而不是 ftp。

如果您在测试数据库服务器上有一个由 mysqldump 创建的转储文件,并且您经常更新它。我认为您可以通过使用 rsync 传输它来节省时间(如果不是磁盘空间)。 Rsync 将使用 ssh 并压缩数据进行传输,但我认为本地和远程文件都应该/可以解压缩。

Rsync 只会传输文件的已更改部分。

可能需要一些时间来确定转储文件中到底发生了什么变化,但传输应该很快。

但我必须承认,我从未使用过半千兆字节的转储文件。

Use an efficient transfer method, rather than ftp.

If you have a dump file created by mysqldump, on the test db server, and you update it every so often. I think you could save time (if not disk space) by using rsync to transfer it. Rsync will use ssh and compress data for the transfer, but I think both the local and remote files should/could be uncompressed.

Rsync will only transfer the changed portion of a file.

It may take some time to decide what, precisely, has changed in a dump file, but the transfer should be quick.

I must admit though, I've never done it with a half-gigabyte dump file.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文