2

I have a huge number of files existing on some server and I want to move them all to mysql instead. What is the best way to do that in terms of performance as I mentioned the number of files is pretty big . And if there is any 3rd party script existing to do that.

Eng.Helewa
  • 69
  • 1
  • 9
  • 1
    what do u mean by move them to mysql ? is it saving the entire data in each file to mysql tables?? – ɹɐqʞɐ zoɹǝɟ Jun 20 '15 at 09:15
  • 1
    `files` to database ?? !! – Sulthan Allaudeen Jun 20 '15 at 09:19
  • possible duplicate of [How to insert a file in MySQL database?](http://stackoverflow.com/questions/5959043/how-to-insert-a-file-in-mysql-database) – D4V1D Jun 20 '15 at 09:20
  • i think he means data files. i believe he wants a solution to moving data stored in files to database. – Umair Khan Jun 20 '15 at 09:20
  • @UmairKhan How can you assume the OP wants to store the *data* stored in the file in MySQL? AFAIK, he wants to store the *file* itself. – D4V1D Jun 20 '15 at 09:22
  • I said I think , so further clarification from the OP is required. You have right to disagree :) – Umair Khan Jun 20 '15 at 09:24
  • I have files I want to read those files and store them as blob. I know that's a bad practice because I already storing them to HDD and only store a link to that file. But my customer want them to be move to a database. – Eng.Helewa Jun 21 '15 at 12:27

1 Answers1

-2

You should NEVER store your files in MySQL. Keep your files in a folder, and put the paths to the files in your database.

The reason why you shouldn't do it, is because the filesystem itself are optimized for one thing.. Storing files, you'll have way more performance storing the files on disk compared to a database. Sure a database usually have a lot of data in memory, since MySQL tries to put everything in memory if it can.

But the filesystem does the same. Frequently accessed files will end up in memory to save IO on the disk itself, you can read more about this with file system cache and virtfs.

Mauran Muthiah
  • 1,198
  • 9
  • 21