how to store video in database using mysql?

I try to store a video file into database using MySQL, But i don’t known how do store
video file into database. I try following query but it didn’t work.

     CREATE TABLE GAME  (
               GAME_ID INTEGER NOT NULL PRIMARY KEY,
               GAME_NAME VARCHAR (20),
               VIDEO  LONGBLOB );


INSERT INTO GAME  VALUES(3, "Termonator2", 
LOAD_FILE("C:UsersPublicVideosSample Videos"));

Please give me any reference or hint.
Any help is appreciated.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

I would advise you to store the video file in a file directory, and only store the filename in your MySQL database.

This way, you can keep a light database.

Method 2

you need to add two slash in path.
Check following query.it’s work with me.
use this

INSERT INTO GAME values (3, 'Termonator2',LOAD_FILE("C:\Users\Public\Videos\Sample Video\test.mpg"));

instead of

INSERT INTO GAME  VALUES(3, "Termonator2", 
LOAD_FILE("C:UsersPublicVideosSample Videos"));

enjoy…..

Method 3

LOAD_FILE("C:UsersPublicVideosSample Videos") is a DIRECTORY. You forgot the video name and extension.

Should be: LOAD_FILE("C:UsersPublicVideosSample Videosvideoname.avi") for example.

But like everyone pointed out, this is a bad idea. Don’t store videos in a database.

Method 4

First of all, I would suggest you to not store the video file in your database, this is a wrong approach.

Store only video file names and through which you can fetch video from a directory.

But your answer is:

INSERT INTO GAME values (3, 'Termonator2',LOAD_FILE("C:\Users\Public\Videos\Sample Video\video.mp4"));

Method 5

try

C:UsersPublicVideosSample Videosfilename.ending

instead of

C:UsersPublicVideosSample Videos

Method 6

Just put your videos in the C: directory somewhere. The whole User/Videos thing seems to be hidden. I created a C:/videos directory and placed my videos in it!


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x