解决bug:the --secure-file-priv option so it cannot execute this statement

文 | Promise Sun


一、Bug问题

系统环境:win11
运行环境:MySQL 8.0.28
图形工具:Navicat Premium 15

Bug描述: 在备份数据库时,运行SQL语句时报错:
eg:SQL语句:

select * from mysql_test.customers into outfile 'C:/BACKUP/backupfile.txt'
fields terminated by ','  optionally enclosed by '''' lines terminated by '?';

报错信息:

二、Bug分析

1.首先,翻译信息

报错信息:

The MySQL server is running with the --secure-file-priv option so it cannot execute this statement

翻译:MySQL服务器运行时,无法执行secure-file-priv选项语句。

2.然后,分析报错信息

1)mysql文件的导入和导出路径有默认的设置,secure-file-priv出现问题,说明SQL语句中传入的文件路径与默认的路径冲突,才会报错。

secure-file-priv的值有3种情况:
secure_file_prive=null             —— 默认值为null,限制mysql,禁止导入导出文件
secure_file_prive=“”                —— 表示不限制路径,允许mysql 导入导出文件
secure_file_prive=“D:/path”    —— 指定路径,表示只允许在该路径目录下导入导出文件(这里的路径值可以自己设置)

2)查看secure-file-priv当前的值
可以使用下面两种命令行方式查看secure-file-priv当前的值任选其一即可
第一种查看方式:

show variables like '%secure%';

显示结果

第二种查看方式:

show variables like "secure_file_priv";

显示结果

3)从上面显示结果中,可以明确系统默认禁止mysql导入导出文件。重新设置一下secure-file-priv的值即可。

三、解决方案

1) 首先,找到你的mysql安装路径下的my.ini文件

注:若安装路径下没有找到此文件,可以在此安装路径下自己新建一个my.ini文件。
下图是本人的mysql安装路径,仅供参考

2) 打开my.ini文件,在文件末尾设置secure-file-priv的值。

secure-file-priv的值可以指定路径设置,也可以不限制路径。区别是指定路径相对安全,但在mysql导入导出文件时则必须在指定路径下才可以,否则依然会报错。

注:本人直接设置不限制路径,你可以自行决定是否设置指定路径

secure_file_prive=“” 

3) 然后,my.ini文件 点击另存为窗口,编码选择ANSI,保存。

4) 验证secure-file-priv当前的值是否设置成功。

注:成功设置后,就可以使用SQL语句了。
命令行查看:

show variables like "secure_file_priv";

验证结果:

  • 2
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
"The MySQL server is running with the LOCK_WRITE_GROWTH option so it cannot execute this statement." 这个错误信息表明MySQL服务器正在使用LOCK_WRITE_GROWTH选项,导致无法执行该语句。这是阿里云的一个保护策略,当空间剩余不足时,禁止数据写入。你可以使用Navicat执行以下SQL语句来查看剩余空间大小。另外,有时候这个问题可能需要重启MySQL才能释放,因为这个文件是系统文件,很难找到。而且,如果使用了空间后,它并不会自动释放,这确实很令人困扰。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [mysql报错The MySQL server is running with the LOCK_WRITE_GROWTH option so it cannot ...](https://blog.csdn.net/qq_42500588/article/details/126420879)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* [The MySQL server is running with the LOCK_WRITE_GROWTH option so it cannot execute this statement](https://blog.csdn.net/u013752219/article/details/131003195)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值