How to insert image in mysql database(table)?

后端 未结 8 2003
野趣味
野趣味 2020-12-13 05:08

I want to insert image into a table like

 CREATE TABLE XX_SAMPLE(ID INT
                       ,IMAGE BLOB);

So can you help out form how t

相关标签:
8条回答
  • 2020-12-13 05:43

    I tried all above solution and fail, it just added a null file to the DB.

    However, I was able to get it done by moving the image(fileName.jpg) file first in to below folder(in my case) C:\ProgramData\MySQL\MySQL Server 5.7\Uploads and then I executed below command and it works for me,

    INSERT INTO xx_BLOB(ID,IMAGE) VALUES(1,LOAD_FILE('C:/ProgramData/MySQL/MySQL Server 5.7/Uploads/fileName.jpg'));
    

    Hope this helps.

    0 讨论(0)
  • 2020-12-13 05:45

    This is on mysql workbench -- give the image file path:

    INSERT INTO XX_SAMPLE(id,image) VALUES(3,'/home/ganesan-pc/Documents/aios_database/confe.jpg');
    
    0 讨论(0)
提交回复
热议问题