将BLOB类型映像插入MySQL数据库

时间:2015-04-01 16:03:41

标签: mysql windows-8.1

我使用以下方法创建了一个数据库:

create table test.data(
  id int not null,
  description varchar(255),
  image blob not null,
  primary key (id)
);

这很有用。然后我尝试使用以下方法将数据插入表中:

insert into test.data
values(1, "Image one", LOAD_FILE('D:\Ecommerce\site\image1.jpg'));

但我最后说错误column 'image' cannot be null

如何将图像插入mysql数据库?我正在使用MySQL Query Browser和Windows 8.1。

1 个答案:

答案 0 :(得分:1)

LOAD_FILE返回null。请尝试以下方法:

  • 双重转义文件路径中的slach(对于Win)。
  • 必须为您的mysql用户明确授予FILE权限。确保已启用它。

如果不起作用,请检查 LOAD_FILE_Doc 并确保满足所有条件。

相关问题