MySQL 如何使用mysql将视频存储在数据库中?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10383886/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 13:11:20  来源:igfitidea点击:

how to store video in database using mysql?

mysqlvideostore

提问by Dnyani

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.

我尝试使用 MySQL 将视频文件存储到数据库中,但我不知道如何将视频文件存储到数据库中。我尝试以下查询,但没有奏效。

     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 reference or hint.
Any help is appreciated.

请给我任何参考或提示。
任何帮助表示赞赏。

回答by adrien

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

我建议您将视频文件存储在文件目录中,并且只将文件名存储在 MySQL 数据库中。

This way, you can keep a light database.

这样,您就可以保持一个轻量级的数据库。

回答by Sandip Armal Patil

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

enjoy.....

请享用.....

回答by Jimmy D

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

LOAD_FILE("C:\Users\Public\Videos\Sample Videos")是一个目录。您忘记了视频名称和扩展名。

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

Should be: LOAD_FILE("C:\Users\Public\Videos\Sample Videos\videoname.avi")例如。

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

但就像每个人都指出的那样,这是一个坏主意。不要将视频存储在数据库中。

回答by juergen d

try

尝试

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

instead of

代替

C:\Users\Public\Videos\Sample Videos

回答by user2512553

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!

只需将您的视频放在 C: 目录中的某个位置。整个用户/视频的事情似乎被隐藏了。我创建了一个 C:/videos 目录并将我的视频放在其中!

回答by Ritesh Jha

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"));