The simplest explanation is load_file
did not load the file. This is probably because it didn't find it. It didn't find it because load_file
runs on the server. It's looking for your file on the MySQL server. From the docs:
To use this function, the file must be located on the server host, you must specify the full path name to the file, and you must have the FILE privilege. The file must be readable by the server and its size less than max_allowed_packet bytes. 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.
As Barmar suggests, debug with a simple SELECT LOAD_FILE('D:\\dice.jpg')
.
Instead, use load data
with the local option.
Note that storing files in a database is inefficient. They take up a lot of space and they consume a lot of previous database server resources. Instead, store a path to the file.
For example, a web application wanting to serve a file. If the file is in the database it has to query the file, retrieve the file from the database, store the file, and then serve its copy. If you just store the path it queries the file's path and serves the local file directly.