How to insert image directly in mysql using command?
Posted by: (103.230.107.---)
Date: June 27, 2019 07:21PM

Hello sir,
I am trying to inset a small image img.png (57.7Kcool smiley into mysql database. Table structure is id(int) and image(blob). I directly inserting image can cause problems but I need this for test purpose. I am using windws 10 os and WampServer 3.1.7 64 bit. (mysql 5.7.24) and My image is located at local disk drive F.

I can insert the image using localhost/phpmyadmin but
when I try command-line using the following command:

insert into image(id,image) values (2,load_file('f:\img.png'));


insert into image(id,image) values (2,load_file('f:\\img.png'));

error occurs :-
ERROR 1048 (23000): Column ‘image’ cannot be null

Please help. 

Re: How to insert image directly in mysql using command?
Posted by: RiggsFolly (Moderator)
Date: June 27, 2019 07:28PM


This is NOT a WAMPServer issue. Please look at my signature where you will find links to the MySQL and PHP Documentation

(Windows 10 Pro 64bit) (Wampserver 3.1.9 32bit & 64bit)
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.16>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your MySQL databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Sorry, only registered users may post in this forum.