If the image is located on your MySQL host, you could use the LOAD_FILE() command for storing an image in a BLOB:
-- Using the following table as an example:
CREATE TABLE MyTable (
image BLOB
);
-- This will insert a file in a BLOB column.
INSERT INTO MyTable (image) VALUES(LOAD_FILE('/tmp/image.png'));
该文件路径为'd:/tmp/image1.png'
Make sure that the image file is readable by MySQL, and also make sure that your MySQL user has the FILE privilege.
To grant the FILE privilege, log-in as root and execute:
GRANT FILE ON *.* TO 'mysql_user'@'localhost';
|