Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best way to store Binary data (images, pdf's, mp3's, videos ect) in mysql and why?

What is the best way to store Binary data (images, pdf's, mp3's, videos ect) in mysql and why? What i would love to know is how you do it(as developers) and why? Also how the big sites do it?

Thank you in advance ;-)

like image 956
Imran Avatar asked Jun 22 '10 11:06

Imran


People also ask

How do you store binary data?

Binary data can be stored in a table using the data type bytea or by using the Large Object feature which stores the binary data in a separate table in a special format and refers to that table by storing a value of type oid in your table.

Can videos be stored in MySQL?

Of course you can. But database including MySQL is not good at storing unstructured data like pictures, video, mp3, etc. If you just store a few small files ,it's OK, but if you want to scale out to store a lot of files, you should chose another way.

Which datatype is used to store images in databse?

A Binary Large Object ( BLOB ) is a MySQL data type that can store binary data such as images, multimedia, and PDF files.

What are binaries in database?

Binary data is a type of data that is represented or displayed in the binary numeral system. Binary data is the only category of data that can be directly understood and executed by a computer. It is numerically represented by a combination of zeros and ones.


1 Answers

To store Binary data in MySQL Blob can be used: MySQL Manuel: 10.4.3. The BLOB and TEXT Types

Although if it isn't really necessary I wouldn't store binary data in a database, because the central reasons for storing data in MySQL etc. (like Join, Index, ...) can hardly be used with this data types. Blob also is degrading the overall database performance.

Perhaps you build a separate table for files where you store several aspects and a filesystem path...

like image 150
FloE Avatar answered Sep 30 '22 06:09

FloE