当前位置:网站首页>导出数据提示--secure-file-priv选项问题的解决方法
导出数据提示--secure-file-priv选项问题的解决方法
2022-06-11 17:07:00 【jacklin_001】
mysql可使用 into outfile 参数把表中数据导出到csv,例如可用以下命令把user表的数据导出到user.csv
1 |
|
执行后,user表的数据会导出到/tmp/user.csv。
参数说明:
into outfile ‘导出的目录和文件名’
指定导出的目录和文件名
fields terminated by ‘字段间分隔符’
定义字段间的分隔符
optionally enclosed by ‘字段包围符’
定义包围字段的字符(数值型字段无效)
lines terminated by ‘行间分隔符’
定义每行的分隔符
问题分析
以上命令在mysql5.6下运行没有问题,但在mysql5.7下运行则出现了以下错误。
ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
查看官方文档,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 的值,默认为NULL,表示限制不能导入导出。
1 2 3 4 |
|
因为 secure_file_priv 参数是只读参数,不能使用set global命令修改。
1 2 |
|
解决方法
打开my.cnf 或 my.ini,加入以下语句后重启mysql。
1 |
|
查看secure_file_priv修改后的值
1 2 3 4 |
|
修改后再次执行,成功导出。
';
执行后,user表的数据会导出到/tmp/user.csv。
参数说明:
into outfile ‘导出的目录和文件名’
指定导出的目录和文件名
fields terminated by ‘字段间分隔符’
定义字段间的分隔符
optionally enclosed by ‘字段包围符’
定义包围字段的字符(数值型字段无效)
lines terminated by ‘行间分隔符’
定义每行的分隔符
问题分析
以上命令在mysql5.6下运行没有问题,但在mysql5.7下运行则出现了以下错误。
ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
查看官方文档,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 的值,默认为NULL,表示限制不能导入导出。
1 2 3 4 |
|
因为 secure_file_priv 参数是只读参数,不能使用set global命令修改。
1 2 |
|
解决方法
打开my.cnf 或 my.ini,加入以下语句后重启mysql。
1 |
|
查看secure_file_priv修改后的值
1 2 3 4 |
|
修改后再次执行,成功导出。
1 2 |
|
边栏推荐
- Research Report on operation mode and investment opportunities of China's aluminum industry 2022-2028
- MATLAB中histogram函数的使用
- Difference between select into from and insert into select
- SQL injection attack under seed emulator (including SQL environment configuration)
- LeetCode-384. 打乱数组
- Chip mass production, oppo entering a new era?
- 【pytest学习】pytest 用例执行失败后其他不再执行
- cocoapod只更新指定库(不更新索引)
- Redis - learn five types of NoSQL
- What products are good for cross-border e-commerce? What are the top selling categories?
猜你喜欢

LeetCode——42. 接雨水(双指针)

多任务学习经典品读:MMoE模型篇

Katalon Studio Enterprise

Typescript learning notes (II)

tornado环境搭建及基本框架搭建——熟悉的hello world

10 times faster than 5g. Are you ready for 10 Gigabit communication?

Report on the operation situation and future prospects of China's gear oil industry (2022-2028)

Research Report on operation mode and investment opportunities of China's aluminum industry 2022-2028

^31原型面试题

^31 prototype interview questions
随机推荐
2022 national question bank and mock examination for safety officer-b certificate
Switching power supply circuit diagram and principle 12V analysis - detailed version
GemBox.Bundle 43.0 Crack
Oracle生成不重复字符串 sys_guid()与Mysql生成唯一值
Oracle 分析函数 over 和MySQL 实现类似效果写法
tornado环境搭建及基本框架搭建——熟悉的hello world
核密度估计(二维、三维)
Chip mass production, oppo entering a new era?
Analysis report on future development trend and investment suggestions of global and Chinese soybean protein industry 2022-2028
虚拟局域网划分与虚拟局域网间路由(VLAN)
Elasitcsearch basic learning notes (1)
闭包的简单理解
Song of the sea in 5g Era
所见即所得的 markdown 编辑器:Typora
C语言:使用.h和.c文件遇到的问题总结
2022 molten welding and thermal cutting work license and simulation examination
ASP. Net education OA system source code education industry OA system source code with document
select into from 和 insert into select 区别
Elasitcsearch基础学习笔记(1)
MATLAB中histogram函数的使用