It depends on how much memory you have on the machine. If you are not limited by the size of RAM, you can try to read the entire file, blow it into an array and generate an insert request at a time.
You will probably need to create multiple insertion queries due to database restrictions (e.g. max_allowed_packet in mySQL)
If you do not have enough memory, you will need to read the file in a few steps (pieces of bytes). You can create multiple insertion requests.
fopen and fread functions can be useful.
source share