views:

78

answers:

1

I want to write a program which will backup an entire drive in a MySQL server using java, but I am confused.

How do I create the table (what data types?), how do i insert the row like what should be the primary key, and what should be the max size of each file be?

If you have any suggestion please help me out. Thank you for sparing you time.

+4  A: 

If the zip file is located on your MySQL host, you could use the LOAD_FILE() function to store the file in a BLOB field:

CREATE TABLE your_table (id INT, zip_file BLOB);

INSERT INTO MyTable (id, image) VALUES(1, LOAD_FILE('/tmp/your_file.zip'));

You have to make sure that the zip file is readable by MySQL, and that the MySQL user has the FILE privilege. To grant the FILE privilege, log-in as root and execute:

GRANT FILE ON *.* TO 'mysql_user'@'localhost';
Daniel Vassallo