Upload image directly through mySQL Command Line

前端 未结 6 1088
春和景丽
春和景丽 2020-12-18 19:12

I have a certain table in mySQL which has a field called \"image\" with a datatype of \"BLOB\". I was wondering if it is possible to upload an image in that field directly f

6条回答
  •  爱一瞬间的悲伤
    2020-12-18 19:48

    Try using the LOAD_FILE() function.

    UPDATE `certain_table`
    SET image = LOAD_FILE('/full/path/to/new/image.jpg')
    WHERE id = 1234;
    

    See the manual for requirements about the path to the filename, privileges, etc.

提交回复
热议问题