为什么在MySQL中存储二进制数据? [英] Why store binary data in MySQL?

查看:730
本文介绍了为什么在MySQL中存储二进制数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有点困惑 - 在DB中存储二进制数据的优点是什么?是因为安全原因,还是有一些更复杂的动机,我看不到?

I'm a little confused - what are the pros of storing binary data in DB? Is it for security reasons, or there are some more complicated motives i don't see?

感谢您的时间。

推荐答案

与什么?将它放在文件系统中?

As opposed to what? Putting it in the filesystem?

使用文件系统进行二进制文件存储的缺点是:

The drawbacks to using the filesystem for binary file storage would be:


  • 您无法获得ACID合规性;

  • you don't get ACID compliance;

如果您可能在多个服务器平衡,故障转移),您必须制定某种共享文件存储,以避免后端不同步;

if you might be hosting the application on more than one server (eg load-balancing, failover), you have to work out some kind of shared file storage to avoid the backend getting out of sync;

只有一个存储后端

因此,使用基于数据库的存储,您不必担心创建文件夹具有对Web用户的写访问权限,整个应用程序可以是只读的。如果需要移动应用程序,则可以将其从源代码控制中检出,并将其指向数据库,而不必跨越多个文件数据。您的数据库备份可以覆盖所有内容,而不必具有单独的文件备份步骤。

So with database-only storage, you don't have to worry about creating a folder with write access for the web user, the whole app can be read-only. If you need to move the application, you can just check it out of source control and point it to the database without having to copy more file data across. Your database backups can be covering everything instead of having to have a separate file backup step. And so on.

另一方面,数据库BLOB存储的缺点:

On the other hand the drawbacks to database BLOB storage:


  • 难以处理非常大的文件;

  • unwieldy for very large files;

您无法使用网络服务器高效地提供文件。 p>

you don't get to use the web server to serve the files up efficiently for free.

这篇关于为什么在MySQL中存储二进制数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆