用用sql语句将插入图片到mysql数据库中

您所在的位置:网站首页 mysql增加数据库内存数能直接添加么 用用sql语句将插入图片到mysql数据库中

用用sql语句将插入图片到mysql数据库中

2024-07-12 23:58| 来源: 网络整理| 查看: 265

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';


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3