首页 > 解决方案 > 如何在 Ubuntu 20.04 上更改 MySQL 中的安全文件私有选项

问题描述

我正在尝试在 Ubuntu 20.04 上使用 OUTFILE 并收到此错误:MySQL 服务器版本:8.0.21

代码:

mysql> select * into OUTFILE '/home/yash/Desktop/data2.txt' from ticket;

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

我尝试了很多解决方案,但在 Ubuntu 20.04 上不起作用

如果有人可以为 Ubuntu 20.04 和 MySQL 8.0.21 提供解决方案,那么将不胜感激。

标签: mysqllinuxubuntu-20.04into-outfile

解决方案


You can use

SHOW VARIABLES LIKE "secure_file_priv"; 

to see the directory that MySQL thinks that it is secure to load or save files.

You have now two options:

  1. Move your file to the directory specified by secure-file-priv.

  2. Disable secure-file-priv. This must be removed from startup and cannot be modified dynamically. So you have to change it in my.conf

In my.con you should find secure-file-priv= and change it to

[mysql]
secure-file-priv='/home/yash/Desktop/'

So that your desktop will become a save directory.

And you can disable the secure file option, which is not recommended by

[mysql]
secure-file-priv=''

推荐阅读