如何可靠地恢复 MySQL blob

发布于 2024-09-14 14:40:31 字数 838 浏览 3 评论 0原文

多年来我一直使用以下命令备份 MySQL 数据库: mysqldump myDatabaseName -u root > myBackupFile.sql

备份似乎工作正常...

然后我想将其中一个备份恢复到另一个命名的数据库,所以我这样做了: mysql myNewDatabaseName -u root mysql myNewDatabaseName -u root < myBackupFile.sql

我遇到了一些关于日志文件大小的错误,因此我停止了 Mysql 并删除了日志文件,并在 my.ini 文件中设置了以下参数并重新启动了 mysql。

innodb_log_file_size=64M

innodb_log_buffer_size=8M

恢复现已完成,没有错误,但包含 Blob 的三个表之一永远不会恢复。

我的 max-allowed-packet 设置为 32M

数据库备份大小约为 2.2 GB,该大小的大部分位于无法恢复的表中。如果我在恢复的数据库上运行 mysqldump,大小为 185 MB。

我现在尝试使用选项 --hex-blob 执行 mysqldump,但我还没有尝试恢复该文件(3.9 GB)。

我确实需要一种万无一失的备份和恢复方法,因为我现有的备份似乎毫无价值。我特别担心的是,据我所知,它“默默地失败”,没有错误日志条目。

环境是windows server 2003 sp2

任何帮助表示赞赏!

乔治

I have been backing up a MySQL database for several years with the command:
mysqldump myDatabaseName -u root > myBackupFile.sql

The backups have appeared to work fine...

I then wanted to restore one of the backups to a different named database so I did:
mysql myNewDatabaseName -u root < myBackupFile.sql

I got some errors about logfile size so I stopped Mysql and removed the logfiles and set the following parameters in the my.ini file and restarted mysql.

innodb_log_file_size=64M

innodb_log_buffer_size=8M

The restore now completes with no errors but one of the three tables which contains blobs is never restored.

My max-allowed-packet is set to 32M

The database backup size is about 2.2 GB the majority of that size being in the table that does not restore. If I run a mysqldump on the restored database the size is 185 MB.

I have now tried doing a mysqldump with the option --hex-blob but I have not tried to restore that file (3.9 GB) yet.

I really need to have a bombproof way to backup and restore as my existing backups appear worthless. I am particularly concerned that it "fails silently" with no error log entries as far as I can see.

The environment is windows server 2003 sp2

Any help appreciated!

George

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

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

发布评论

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

评论(2

渡你暖光 2024-09-21 14:40:31

我设法使用以下 mysqldump 命令备份和恢复 blob:

mysqldump --opt  --skip-extended-insert --max_allowed_packet=128M -u root myDB > filename

不确定它是否在命令行上指定 max_allowed_pa​​cket 或执行此操作的 skip-extended-insert诡计。

我假设我的 max_allowed_pa​​cket 为 32M,但我认为在 mysql 配置文件中它位于 [mysqld] 部分,因此可能不适用于转储。

我仍然不明白为什么转储或恢复时都没有错误。

I managed to back up and restore the blobs by using the following mysqldump command:

mysqldump --opt  --skip-extended-insert --max_allowed_packet=128M -u root myDB > filename

Not sure if it’s specifying max_allowed_packet on the command line or the skip-extended-insert that did the trick.

I assumed that my max_allowed_packet of 32M was being used, but I think that in the mysql config file it is in the [mysqld] section and so probably does not apply to dump.

I still don’t understand why I got no errors on either the dump or the restore.

零度℉ 2024-09-21 14:40:31

mysqldump --skip-extended-insert 可以工作,但恢复时性能会降低 100 倍,因此不是一个可行的选择。

当您进行备份时,max_allowed_pa​​cket 会被mysqldump 忽略(由设计?)实际的补充是net_buffer_length。因此,请确保您的 max_allowed_pa​​cket 大于您的 net_buffer_length 并且它应该可以工作。如:

mysqldump -u root --net_buffer_length=100k oldDB > backup.sql
mysql -u root --max_allowed_packet=10M newDB < backup.sql

mysqldump --skip-extended-insert works but can reduce performance by 100x on restore, making it not a viable choice.

When you do the backup, max_allowed_packet is ignored by mysqldump (by design?) The actual complement is net_buffer_length. So make sure your max_allowed_packet is bigger than your net_buffer_length and it should work. As in:

mysqldump -u root --net_buffer_length=100k oldDB > backup.sql
mysql -u root --max_allowed_packet=10M newDB < backup.sql
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文