I
I
Ivan Melnikov2018-04-10 16:05:59
MySQL
Ivan Melnikov, 2018-04-10 16:05:59

How to insert a photo into a MEDIUMBLOB field from the console in MySQL 5.7?

I can not.
Table:

CREATE TABLE Photo(
id INT NOT NULL PRIMARY KEY,
data MEDIUMBLOB);

Write a write request like this:
INSERT INTO Photo VALUE(1, LOAD_FILE('D:/123.jpg'));

The request passes without error, but NULL is written in the data field. What am I doing wrong?5accb69db34f7592347907.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lazy @BojackHorseman MySQL, 2018-04-10
@immelnikoff

LOAD_FILE(file_name)
Reads the file and returns the file contents as a string. 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 all 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.
If the file does not exist or cannot be read because one of the preceding conditions is not satisfied, the function returns NULL.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question