加载数据infile数据库访问权限/权限(Load Data infile database access Permissions / privileges)

我需要从客户端计算机加载CSV文件到MySQL服务器数据库。 我正在尝试LOAD DATA INFILE。

我的困惑是关于使用所需的访问权限 - LOAD DATA INFILE - LOAD DATA LOCAL INFILE

之前我认为我需要FILE权限才能同时使用它们。

我在mysql文档中遇到过这一行:

在读取位于服务器上的文本文件时,文件必须驻留在数据库目录中,或者所有文件都可读。 此外,要在服务器文件上使用LOAD DATA INFILE,您必须具有FILE权限。 请参见第6.2.1节“MySQL提供的权限”。 对于非LOCAL加载操作,如果secure_file_priv系统变量设置为非空目录名,则要加载的文件必须位于该目录中。

看着这个,我感到很困惑。

我是否需要FILE权限才能使用LOCAL选项从客户端计算机加载FILE?

I need to load a CSV file from client machine to MySQL server database. I am trying LOAD DATA INFILE.

My confusion is regarding ACCESS PERMISSIONs required to use - LOAD DATA INFILE - LOAD DATA LOCAL INFILE

Earlier I believed that I need FILE privilege to use both of them.

I came across this line in mysql documentation :

when reading text files located on the server, the files must either reside in the database directory or be readable by all. Also, to use LOAD DATA INFILE on server files, you must have the FILE privilege. See Section 6.2.1, “Privileges Provided by MySQL”. For non-LOCAL load operations, if the secure_file_priv system variable is set to a nonempty directory name, the file to be loaded must be located in that directory.

Looking at this, I got confused.

Do I need FILE privilege to load FILE from client machine using LOCAL option?

最满意答案

我们不需要FILE权限来将数据文件从远程机器加载到MySQL服务器。 我们需要在客户端计算机上启用--local-infile选项。

当我们尝试加载MySQL服务器上存在的数据文件时,我们需要FILE权限。 另外,mysql demon也应该从放置数据文件的目录访问READ 。

We do not need FILE privilege to LOAD data-file from a remote machine to MySQL Server. We need --local-infile option on Client machine enabled for that.

We need FILE privilege when we are trying to LOAD a data-file which is present on MySQL server. Additionally, mysql demon should also have access to READ from directory where data-file is placed.

更多推荐