'MySQL secure-file-priv=""

I have next problem: I want to insert in a table an image (LONGBLOB). First of all, I successfully inserted the image from C:\\ProgramData\\MySQL\\MySQL Server 8.0\\Uploads (secure-file-priv = "C:\ProgramData\MySQL\MySQL Server 8.0\Uploads") and then I set secure-file-priv="" in order to insert images from any location but NULL value is inserted. Can I upload images from any location? If so, how?

This is my table:

enter image description here

And this is the query:

INSERT INTO `soccertrackerdev`.`test`(`id`,`image`)
VALUES(4, LOAD_FILE('C:/Users/ionut.puiu/Desktop/Untitled.png'));

And the message after run the query is:

enter image description here



Solution 1:[1]

When you set this in your ini file, MySQL starts to obey:

secure-file-priv=""

(The setting for local_infile does not matter, in this case.)

This must be the difference between empty and set to NULL in the docs:

  • If empty, the variable has no effect. This is not a secure setting.

  • If set to the name of a directory, the server limits import and export operations to work only with files in that directory. The directory must exist; the server does not create it.

  • If set to NULL, the server disables import and export operations.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Luuk