如何把視頻檔案直接儲存到MySQL資料庫裡

來源:互聯網
上載者:User

測試一下如何把視頻檔案存放在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可能出現以下錯誤

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.