如何可靠地恢复 MySQL blob
多年来我一直使用以下命令备份 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我设法使用以下 mysqldump 命令备份和恢复 blob:
不确定它是否在命令行上指定
max_allowed_packet
或执行此操作的skip-extended-insert
诡计。我假设我的
max_allowed_packet
为 32M,但我认为在 mysql 配置文件中它位于 [mysqld] 部分,因此可能不适用于转储。我仍然不明白为什么转储或恢复时都没有错误。
I managed to back up and restore the blobs by using the following mysqldump command:
Not sure if it’s specifying
max_allowed_packet
on the command line or theskip-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.
mysqldump --skip-extended-insert 可以工作,但恢复时性能会降低 100 倍,因此不是一个可行的选择。
当您进行备份时,
max_allowed_packet
会被mysqldump
忽略(由设计?)实际的补充是net_buffer_length
。因此,请确保您的max_allowed_packet
大于您的net_buffer_length
并且它应该可以工作。如: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 bymysqldump
(by design?) The actual complement isnet_buffer_length
. So make sure yourmax_allowed_packet
is bigger than yournet_buffer_length
and it should work. As in: