Upload image directly through mySQL Command Line

前端 未结 6 1095
春和景丽
春和景丽 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:42

    LOAD_FILE works only with certain privileges and if the file is on the server. I've found out a way to make it work completely client side:

    mysql -e "update mytable set image=FROM_BASE64('`base64 -i image.png`')" DBNAME
    

    The idea is to encode the image to base64 on the fly and let then MySql decode it.

提交回复
热议问题