将BLOB类型映像插入MySQL数据库
我使用以下方法创建了一个数据库:将BLOB类型映像插入MySQL数据库,mysql,windows-8.1,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'));
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'));
但我最后出现了一个错误,即列“image”不能为null
如何将图像插入mysql数据库?我使用的是MySQL查询浏览器和Windows 8.1。LOAD\u FILE返回空值。请尝试以下操作:
- 双转义文件路径中的slahes(用于Win)
- 必须明确授予mysql用户文件权限。确保已启用它
并确保所有条件都满足。双转义文件路径中的斜杠已生效。(..…加载_文件('C:\\Users\\Public\\Pictures\\image1.jpg');)非常感谢。