Reputation: 5121
Given below is the query for inserting a video in a mySql database.
insert into media(name,data) values ('image', load_file('C:\ao.mp4'))
The table has 2 columns, name and data where data has BLOB data type. The first column is added to the table, but the second column returns null.
I have read the answer provided here, but it is not working.
Upvotes: 1
Views: 16948
Reputation: 9460
Table creation:
CREATE TABLE media (
GAME_ID INTEGER NOT NULL PRIMARY KEY,
name VARCHAR (20),
VIDEO LONGBLOB );
Your insert query would be similar to this
INSERT INTO media values ('File_Name',LOAD_FILE("C:\\Users\\Public\\Videos\\Sample Video\\ao.mp4"));
Result of load_file() was larger than max_allowed_packet (1048576)
You probably have to change it for both the client (you are running to do the import) AND the daemon mysqld that is running and accepting the import.
For the client, you can specify it on the command line:
mysql --max_allowed_packet=100M -u root -p database < dump.sql
Also, change the my.cnf or my.ini file under the mysqld section and set max_allowed_packet=100M or you could run these commands in a MySQL console connected to that same server:
set global net_buffer_length=1000000;
set global max_allowed_packet=1000000000;
(Use a very large value for the packet size.)
To locate .ini File
To configure the client and utility applications, create a new my.ini file in the Windows installation directory. More info here
Upvotes: 2
Reputation: 883
I think you hav 2 options:
Change in the my.ini file. Include the single line under [mysqld] in your file
max_allowed_packet=500M
now restart the MySQL service and you are done
Upvotes: 1