大多数共享主机上是否禁用了 LOAD DATA INFILE?

Does the LOAD DATA INFILE disabled on most shared hostings?

我想在我的插件软件中使用 LOAD DATA INFILE 来显着加快 MySQL 导入过程。我听说一些共享主机禁用了这个(很酷的)功能。这是正确的吗?如果是,他们为什么这样做,是否有可能以某种方式效仿?我的软件旨在 运行 在共享主机上成功。

由于 LOAD DATA INFILE 需要特殊权限,大多数共享主机提供商不提供这些权限:

Non-LOCAL load operations read text files located on the server. For security reasons, such operations require that you have the FILE privilege. See Section 6.2.1, “Privileges Provided by MySQL”. Also, non-LOCAL load operations are subject to the secure_file_priv system variable setting. If the variable value is a nonempty directory name, the file to be loaded must be located in that directory. If the variable value is empty (which is insecure), the file need only be readable by the server.

Using LOCAL is a bit slower than letting the server access the files directly, because the file contents must be sent over the connection by the client to the server. On the other hand, you do not need the FILE privilege to load local files.

来自documentation

MySQL 文档有一个 section dedicated to optimizing INSERT,其中有关于加速插入操作的提示。