How to store video in database using mysql?

I am trying to save a video file in a database using MySQL, but I do not know how to store the video in a database. I am trying to execute a request but it is not working.

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:\Users\Public\Videos\Sample Videos")); 

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

+6
source share
5 answers

you need to add two traits along the way.
Check how query.it works with me.
use it

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

instead

 INSERT INTO GAME VALUES(3, "Termonator2", LOAD_FILE("C:\Users\Public\Videos\Sample Videos")); 

enjoy.....

+6
source

I would advise you to store the video file in the file directory and only store the file name in the MySQL database.

This way you can store a lightweight database.

+7
source

LOAD_FILE("C:\Users\Public\Videos\Sample Videos") is a HANDBOOK. You forgot the name and extension of the video.

Should be: LOAD_FILE("C:\Users\Public\Videos\Sample Videos\videoname.avi") for example.

But, as everyone noted, this is a bad idea. Do not store videos in the database.

+2
source

to try

 C:\Users\Public\Videos\Sample Videos\filename.ending 

instead

 C:\Users\Public\Videos\Sample Videos 
+1
source

Just put your videos in the C: directory. All user / video information seems hidden. I created the C: / videos directory and posted my videos in it!

0
source

Source: https://habr.com/ru/post/914532/


All Articles