If the image is located on your MySQL host, you could use the LOAD_FILE()
function to store the image in a BLOB
field:
CREATE TABLE MyTable (id INT, image BLOB);
INSERT INTO MyTable (id, image) VALUES(1, LOAD_FILE('/tmp/your_image.png'));
You have to make sure that the image file is readable by MySQL, and that the MySQL user has the FILE
privilege. To grant the FILE
privilege, log-in as root and execute:
GRANT FILE ON *.* TO 'mysql_user'@'localhost';