将外部sql文件导入MySQL步骤,MYSQL导出数据报错ERROR 1290 (HY000) 和 ERROR 1 (HY000)

 2023-09-23 阅读 24 评论 0

摘要:问题1、ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement 将外部sql文件导入MySQL步骤, mysql可使用 into outfile 参数把某表中数据导出到一个文件中,例如可用以下命令把AAA 表的数据导出到

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

将外部sql文件导入MySQL步骤,

 mysql可使用 into outfile 参数把某表中数据导出到一个文件中,例如可用以下命令把AAA  表的数据导出到test_out.txt'

mysql导出数据时报错、select * from AAA  into outfile '/home/test/Desktop/test_out.txt';

执行以上mysql语句后报错:The MySQL server is running with the --secure-file-priv option so it cannot execute this statement

用以下mysql语句 查看secure_file_priv 对应的值

 查看 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命令修改。

解决方法

打开my.cnf 或 my.ini,加入以下语句后重启mysql。

修改后再次执行,可以成功导出。 

 问题2:

执行命令select * from AAA  into outfile '/home/test/Desktop/test_out.txt';时,报错如下:

ERROR 1 (HY000): Can't create/write to file '/home/test/Desktop/test_out.txt' (OS errno 13 - Permission denied)

 是权限的问题,将文件导出到tmp目录下是可以的。

 在/web目录下新建一个tt的目录,并赋予777的权限

chown –R 777 /web/tt

因为select into outfile的命令是mysql的daemon来负责写文件操作的,需要对文件具有写的权限,而/web目录的权限为755,mysql不具有对文件写的权限,所以就报不能create/write了,而/tmp是777的权限,所以也就是为什么能够写入的原因

 参考:

MYSQL导入数据出现ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it_jav0a0的博客-CSDN博客

ERROR 1 (HY000): Can't create/write to file '/web/file.txt' (Errcode: 13) - 言止予思 - 博客园

版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。

原文链接:https://hbdhgg.com/5/88460.html

发表评论:

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 匯編語言學習筆記 Inc. 保留所有权利。

底部版权信息