Questions tagged [mysql-loadfile]

33 questions
22
votes
9 answers

How to insert image in mysql database(table)?

I want to insert image into a table like CREATE TABLE XX_SAMPLE(ID INT ,IMAGE BLOB); So can you help out form how to insert image into the above table.
Viru
  • 525
  • 2
  • 7
  • 15
21
votes
6 answers

Upload image directly through mySQL Command Line

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 from the Command Line Client rather than doing it through php...If it is…
BurninatorDor
  • 1,009
  • 5
  • 19
  • 42
16
votes
6 answers

How to use LOAD_FILE to load a file into a MySQL blob?

I tried to load a file into a MySQL blob (on a Mac). My query is INSERT INTO MyTable VALUES('7', LOAD_FILE('Dev:MonDoc.odt')) No error appears but the file is not loaded into the blob.
Flex60460
  • 933
  • 2
  • 18
  • 49
15
votes
5 answers

MySQL LOAD_FILE returns NULL

I want to get SQL LOAD_FILE function to work and have read every single question/answer + documentation about this, but here is what's been happening. When I want to LOAD_FILE from my home directory: mysql> SELECT…
Emir
  • 762
  • 2
  • 8
  • 22
8
votes
3 answers

MySQL LOAD_FILE returning NULL

I'm doing this SELECT LOAD_FILE("/home/user/domains/example.com/public_html/robots.txt") AS tmp FROM tmpTable but it returns NULL. How can I check if this is because I haven't got the FILE privilege or if it's something else? MySQL won't give an…
Simon
  • 5,464
  • 6
  • 49
  • 85
6
votes
3 answers

How to insert images in blob in mysql table using only sql syntax (without PHP)?

Hi,I am new to SQL and I wanted to store images in the database.I already created a column with blob data type and tried to execute the following statement as given here INSERT INTO `abc` (`img`) SELECT BulkColumn FROM…
xxx
  • 73
  • 1
  • 1
  • 5
5
votes
5 answers

LOAD_FILE returns NULL

I am trying to insert an image into my MySQL server. I have done some research and it looks like the best way to do that is through LOAD_FILE(). However, LOAD_FILE() always returns null. I know there are 4 conditions for LOAD_FILE(): The file…
user2761933
  • 179
  • 1
  • 4
  • 15
4
votes
0 answers

MySQL: Executing LOAD statements inside Transaction from a sql script file

I want to load my tables from some csv files. I want all the data import to be transaction bound i.e., if error occurs in any of the data import, all records loaded in other tables are also rolled back. The load statements are executed from a sql…
Pratap
  • 655
  • 2
  • 10
  • 20
3
votes
1 answer

Cloud SQL: Python Client API defaults to utf8mb3 character set on CSV file import

I am using Google Cloud's import API to load CSV file in Google Cloud Storage to a Cloud SQL MySQL 5.7 database: https://cloud.google.com/sql/docs/mysql/admin-api/v1beta4/instances/import The import API generates a LOAD DATA INFILE command to MySQL…
3
votes
1 answer

Can't get load_file() working in mysql

I've been struggling for 2 nights now to get load_file() to work, but the results are NULL. I run version "5.6.19-0ubuntu0.14.04.1". Example: mysql> show variables like '%secure%'; +------------------+-------------+ | Variable_name | Value …
MarlonB
  • 63
  • 1
  • 6
2
votes
3 answers

mysql load_file from client

I want to insert a HTML file, which has lots of SQL meta characters (e.g. single quotes) that I do not want to escape manually, into a MySQL table. I though I could make the mysql client load file contents into a variable and simply insert that…
Frederick Nord
  • 1,246
  • 1
  • 14
  • 31
1
vote
1 answer

How to add an image into a table of database on workbench?

I'm trying to insert an image in database table but it gives error every time: Column image cannot be null Whereas the data type of image column is not null as you can see clearly. How can I solve this problem? Execution inside MySQL Workbench:
90 HAQ
  • 11
  • 3
1
vote
1 answer

How do I get MySQL's "load data" to properly import very large integers into a binary(16) field?

I have a file containing ipv6 addresses represented as very large integers. When I import it into mysql the data is wrong. What do I need to do in order to get the load data to properly import the data into a binary(16) column? Schema: CREATE…
Alpha Fighter
  • 110
  • 2
  • 9
1
vote
3 answers

Insert image into MYSQL Table using SQL Statement

I need to insert images in MYSQL database table. The images are stored in the local disk. I am using LOAD_FILE() for inserting the images, but it only stores the path not the image. If it is not possible to insert from local disk means from where…
1
vote
1 answer

ERROR 1083 (42000) at line 1: Field separator argument is not what is expected when using mysql LOAD

I am trying to use mysql load via the shell prompt. I want to load a CSV file directly into the database. mysql -u root -p -h mysql -e "LOAD DATA INFILE 'Subscriber.csv' INTO TABLE temp_data FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED…
tendaitakas
  • 328
  • 5
  • 18
1
2 3