如何使用 LOAD

编程入门 行业动态 更新时间:2024-10-28 15:34:43
本文介绍了如何使用 LOAD_FILE 将文件加载到 MySQL blob 中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我尝试将文件加载到 MySQL blob 中(在 Mac 上).

I tried to load a file into a MySQL blob (on a Mac).

我的查询是

INSERT INTO MyTable VALUES('7', LOAD_FILE('Dev:MonDoc.odt'))

未出现错误,但文件未加载到 blob 中.

No error appears but the file is not loaded into the blob.

推荐答案

手册 声明如下:

LOAD_FILE(file_name)

LOAD_FILE(file_name)

读取文件并以字符串形式返回文件内容.要使用这个功能,文件必须位于服务器主机上,你必须指定文件的完整路径名,并且您必须拥有 FILE特权.该文件必须对所有人可读且其大小小于max_allowed_pa​​cket 字节.如果 secure_file_priv 系统变量是设置为非空目录名,要加载的文件必须是位于该目录中.

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.

如果文件不存在或无法读取,原因之一前面的条件不满足,函数返回NULL.

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

从 MySQL 5.0.19 开始,character_set_filesystem 系统变量控制以文字形式给出的文件名的解释字符串.

As of MySQL 5.0.19, the character_set_filesystem system variable controls interpretation of file names that are given as literal strings.

mysql> UPDATE t
            SET blob_col=LOAD_FILE('/tmp/picture')
            WHERE id=1;

由此,我发现在您的情况下可能出错的不止一件事......

From this, I see more than one thing that could be wrong in your case...

您是否通过了完整路径?权限设置是否正确?函数返回什么?NULL?您是否尝试过使用手册中给出的查询?

这篇关于如何使用 LOAD_FILE 将文件加载到 MySQL blob 中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-15 11:59:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/865017.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   LOAD

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!