授予数据库用户文件夹访问权限 [英] Grant database user folder access

查看:340
本文介绍了授予数据库用户文件夹访问权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下查询从mysql创建csv数据导出:

I'm trying to create a csv export of data from mysql using the following query:

SELECT * INTO OUTFILE '/tmp/result.csv'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
ESCAPED BY '\\'
LINES TERMINATED BY '\n'
FROM getfreepellets WHERE 1

然后出现以下错误:

#1045 - Access denied for user '[username]'@'localhost' (using password: YES)

(已删除用户名,但这是正确的用户名)

(removed username but it's the right one)

我该如何授予该用户访问权限以在服务器上创建文件?

How would I go about granting access to this user to create a file on the server?

我将第一行更改为我的确切家庭路径,并收到了相同的错误.

I changed the first line to be my exact home path, and received the same error.

推荐答案

您可能想 GRANT 您的用户 FILE 特权:

You may want to GRANT your user the FILE privilege:

FILE特权授予您使用LOAD DATA INFILESELECT ... INTO OUTFILE语句以及LOAD_FILE()函数在服务器主机上读写文件的权限.

The FILE privilege gives you permission to read and write files on the server host using the LOAD DATA INFILE and SELECT ... INTO OUTFILE statements and the LOAD_FILE() function.

具有FILE特权的用户可以读取服务器主机上世界上可读的或MySQL服务器可读的任何文件. (这意味着用户可以读取任何数据库目录中的任何文件,因为服务器可以访问这些文件中的任何文件.)FILE特权还使用户可以在MySQL服务器具有写访问权限的任何目录中创建新文件.为了安全起见,服务器不会覆盖现有文件.

A user who has the FILE privilege can read any file on the server host that is either world-readable or readable by the MySQL server. (This implies the user can read any file in any database directory, because the server can access any of those files.) The FILE privilege also enables the user to create new files in any directory where the MySQL server has write access. As a security measure, the server will not overwrite existing files.

要授予FILE特权,请以root用户身份登录并执行:

To grant the FILE privilege, log-in as root and execute:

GRANT FILE ON *.* TO 'your_user'@'localhost';

这篇关于授予数据库用户文件夹访问权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆