gpt4 book ai didi

mysql - 我正在尝试将图像保存在 mySQL 数据库中,但我收到一条错误消息,它是空的

转载 作者:行者123 更新时间:2023-11-30 21:35:03 25 4
gpt4 key购买 nike

我正在尝试将图像插入 MySQL 数据库,但我一直收到此错误;错误代码:1048。

Column 'image' cannot be null. This is the code I am using.

 create table test_img (
id int(10) not null AUTO_INCREMENT PRIMARY KEY,
name varchar(25) not null default '',
image blob not null
)

INSERT INTO test_img(ID,IMAGE) VALUES(1,LOAD_FILE ('C:\\human_centered_design_infographic.jpg'));

最佳答案

来自MySQL manual :

LOAD_FILE(file_name)

Reads the file and returns the file contents as a string. To use this function, the file must be located on the server host, you must specify the full path name to the file, and you must have the FILE privilege. The file must be readable by all and its size less than max_allowed_packet bytes. If the secure_file_priv system variable is set to a nonempty directory name, the file to be loaded must be located in that directory.

If the file does not exist or cannot be read because one of the preceding conditions is not satisfied, the function returns NULL.

您可能会收到 NULL 错误,因为所提到的条件之一适用。

它不是所有人都可读的,或者服务器没有启用文件权限,或者文件大于 max_allowed_pa​​cket 字节。

关于mysql - 我正在尝试将图像保存在 mySQL 数据库中,但我收到一条错误消息,它是空的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54309736/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com