MySQL LOAD

编程入门 行业动态 更新时间:2024-10-25 22:24:53
本文介绍了MySQL LOAD_FILE返回NULL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想使SQL LOAD_FILE 函数正常工作,并且已经阅读了有关此问题的每个问题/解答+文档,但这是正在发生的事情.

I want to get SQL LOAD_FILE function to work and have read every single question/answer + documentation about this, but here is what's been happening.

当我想从主目录中 LOAD_FILE 时:

mysql> SELECT LOAD_FILE('/home/myuser/somefile.txt'); +----------------------------+ | LOAD_FILE('/home/myuser/somefile.txt') | +----------------------------+ | NULL | +----------------------------+ 1 row in set (0.00 sec)

因此,在获得此信息之后,我认为问题可能出在MySQL无法访问我的主目录.我尝试运行此程序,效果很好:

So after getting this, I thought maybe the problem is that MySQL cannot access my home directory. And I tried running this, which worked fine:

SELECT LOAD_FILE('/etc/mysql/myf');

然后SELECT LOAD_FILE('/etc/passwd');也可以正常工作.

所以我说了,这是一个文件/文件夹读取/所有权许可问题.因此,我将文件移至/etc/mysql/中,但仍然无法正常工作.我已经尝试过chown mysql:mysql somefile.txt,但仍然没有运气:

So I said gotcha, it's a file/folder read/ownership permission problem. So, I moved my file into /etc/mysql/ but then it still didn't work. I've tried chown mysql:mysql somefile.txt but still, I had no luck:

mysql> SELECT LOAD_FILE('/etc/mysql/somefile.txt'); +----------------------------+ | LOAD_FILE('/etc/mysql/somefile.txt') | +----------------------------+ | NULL | +----------------------------+ 1 row in set (0.00 sec)

P.S. 1..所有用户组均可读取所有文件,因此无需chmod.但是,如果您要询问的话,我什至尝试了 chmod 777 . 2..我检查了,在MySQL中未设置secure-file-priv变量,因此,不,LOAD_FILE不限于任何路径.

P.S. 1. All files are readable by all user groups, so no need to chmod. But I've even tried chmod 777 if you'd like to ask. 2. I checked, secure-file-priv variable is not set up in MySQL, so no, LOAD_FILE is not restricted to any path.

任何想法在这里可能是什么问题?

Any ideas what might be the problem here?

推荐答案

我发现这与AppArmor有关.我为MySQL禁用了AppArmor,它起作用了. 对于有相同问题的人,请在这里阅读: www.cyberciti.biz/faq/ubuntu-linux-howto-disable-apparmor-commands/

I found out that it has to do with AppArmor. I disabled AppArmor for MySQL and it worked. For people having the same problem, please read here: www.cyberciti.biz/faq/ubuntu-linux-howto-disable-apparmor-commands/

更多推荐

MySQL LOAD

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

发布评论

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

>www.elefans.com

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