How to store video files directly in the MySQL database

Source: Internet
Author: User
Tags mysql database

Test how to store the video file in MySQL data, of course, do not recommend direct storage, because the migration will be cumbersome and prone to problems, the following is just a test function, import jpg, PNG and other pictures similar.

Create a test table, use Longblob or Mediumblob

CREATE TABLE Test (id INTEGER not NULL PRIMARY key,name VARCHAR (), movie Longblob);

Then import the video file

INSERT into Test VALUES (1, ' Titanic ', Load_file ("/tmp/good.mp4"));

Note that the following error may occur if you do not use Longblob

PS: About the Direct deposit picture on the MySQL above has two points benefits:

Easy to do weight, is the same picture only save one.

The most important backup uses the database in a simple way.

Easy to manage, remove unwanted pictures, etc.

Disadvantages:

Not suitable for a large amount of storage, the larger the data storage, the more trouble recovery

Of course, generally still need to do more physical cache, rather than rely on MySQL to direct output.

In short, if the picture is a small picture, like a forum used, and need to pay attention to his advantages can be used, as for the quantity is not specific, you have to think about if the database encountered problems, his redo and migration is convenient. In fact, if it is not a special case of the general existence of the database is not a good choice. Balance his pros and cons.

This article from the "Old Xu's private dish" blog, please be sure to keep this source http://laoxu.blog.51cto.com/4120547/1222046

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/database/MySQL/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.