Home  >  Article  >  Database  >  如何把视频文件直接存储到MySQL数据库里

如何把视频文件直接存储到MySQL数据库里

WBOY
WBOYOriginal
2016-06-07 17:29:463486browse

测试一下如何把视频文件存放在mysql数据里,当然不建议直接存放,因为迁移会很麻烦而且容易出现问题,以下只是测试功能,导入jpg

测试一下如何把视频文件存放在mysql数据里,当然不建议直接存放,因为迁移会很麻烦而且容易出现问题,以下只是测试功能,,导入jpg、png等图片类似。

创建一个测试表test,使用longblob或者mediumblob

CREATE TABLE test (id  INTEGER NOT NULL PRIMARY KEY,name VARCHAR (20),movie  LONGBLOB);

然后把视频文件导入

INSERT INTO test  VALUES(1, 'titanic', LOAD_FILE("/tmp/good.mp4"));

注意,如果不使用longblob可能出现以下错误

linux

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn