mysql 存储二进制数据_为什么在MySQL中存储二进制数据?

bd96500e110b49cbb3cd949968f18be7.png

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?

Thanks for your time.

解决方案

As opposed to what? Putting it in the filesystem?

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

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;

having only one storage backend instead of two makes deployment simpler.

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.

On the other hand the drawbacks to database BLOB storage:

unwieldy for very large files;

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值