暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

select into outline导出文件报错ERROR 1290的解决

张文林 2024-07-04
34
select into outline导出文件报错ERROR 1290的解决

mysql使用select into outline导出文本文件时报错ERROR 1290,导致

导出文本文件不成功。。本文介绍遇到这种情况应该如何解决。

 

一、问题描述 

 

在应用数据中使用select into outline导出文本文件到/mysql/backup/t.txt文件中报ERROR 1290错误,提示 --secure-file-priv参数。

mysql> select * from t into outfile '/mysql/backup/t.txt';

ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement

 

二、问题分析

 

查询secure_file_priv对应值.

mysql> show global variables like '%secure_file_priv%';

+------------------+-------+

| Variable_name    | Value |

+------------------+-------+

| secure_file_priv | NULL  |

+------------------+-------+

1 row in set (0.15 sec)

 

说明:如上所示,secure_file_priv值为null,表示限制不能导入导出.官方文档显示,secure_file_priv参数用于限制LOAD DATA, SELECT …OUTFILE, LOAD_FILE()传到具体指定目录.

secure_file_priv为NULL时,表示限制mysqld不允许导入或导出.

secure_file_priv为/tmp时,表示限制mysqld只能在/tmp目录中执行导入导出,其他目录不能执行.

secure_file_priv没有值时,表示不限制mysqld在任意目录的导入导出.

 

三、问题解决

 

因secure_file_priv为只读参数,使用set global命令修改会出现如下告警.

 

 

mysql> set global secure_file_priv='';

ERROR 1238 (HY000): Variable 'secure_file_priv' is a read only variable

 

 

解决办法:将该参数配置写入参数文件/etc/my.cnf 中,secure_file_priv=''添加到/etc/my.cnf 中,重启数据库。

再查询该参数值,如下:

mysql> show variables like '%secure_file_priv%';

+------------------+-------+

| Variable_name    | Value |

+------------------+-------+

| secure_file_priv |       |

+------------------+-------+

1 row in set (0.02 sec)

 

 

重新导出文本文件,导出成功,如下:

mysql> > select * from t into outfile '/mysql/backup/t.txt';

Query OK, 110 rows affected (0.00 sec)

 

 

 

 

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论