社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  DATABASE

无法将mysql输出写入lcoal文件

user9371654 • 5 年前 • 1531 次点击  

我无法将查询结果写入本地文件。我确信我的查询会产生输出。我可以看。我在ubuntu 18.04上使用mysql工作台。在我添加此行以将输出写入文件之后:

INTO OUTFILE '/var/lib/mysql-files/myproject/out_files/mydata.txt' FIELDS TERMINATED BY ',';

我得到这个错误:

Error Code: 1290. The MySQL server is running with the --secure-file-priv option so it cannot execute this statement

我看了以前的帖子。我确保 /var/lib/mysql-files 是指定的写入路径。这是我得到的输出: mysql>选择@global.secure_file_priv;

+---------------------------+
| @@GLOBAL.secure_file_priv |
+---------------------------+
| /var/lib/mysql-files/     |
+---------------------------+
1 row in set (0.00 sec)

怎么了?

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/47828
 
1531 次点击  
文章 [ 1 ]  |  最新文章 5 年前
Bill Karwin
Reply   •   1 楼
Bill Karwin    6 年前

这个 secure_file_priv 必须准确地命名输出到的目录。不能输出到子目录中。

下面是我刚刚在笔记本电脑上使用mysql 5.6的演示:

mysql> select @@global.secure_file_priv;
+---------------------------+
| @@global.secure_file_priv |
+---------------------------+
| /tmp/                     |
+---------------------------+

mysql> select 123 into outfile '/tmp/foo';
Query OK, 1 row affected (0.00 sec)

检查数据是否已写出:

$ cat /tmp/foo
123

然后尝试子目录:

mysql> select 456 into outfile '/tmp/a/b/text';
ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement

即使我 mkdir -p /tmp/a/b 为了确保在尝试这个子目录之前,它仍然失败。