I would like to take data (some text) from a file and insert it into a mysql field, using a script.
I have tried: mysql -u root -p password dbname << INSERT INTO tblename (fieldname) VALUES (LOAD_FILE('filename'));
and
mysql -u root -p password dbname << EOF INSERT INTO tblename (fieldname) VALUES ('$filename'); EOF
Not even close for either. You can’t “redirect” a string into mysql.
Try
instead.
The second version has even less of a chance to work – you’d just be inserting the name of the file into the database, not the file’s contents.