Mysql – How to upload 1.5GB sql file on thesql

MySQLmysqldump

Whenever I tried to import file in MySql on my Linux Mint system, "You probably tried to upload a file that is too large. Please refer to documentation for a workaround for this limit." this message shows. May anybody please help me that how to import 1.5GB. Thanks

Best Answer

You don't say how you are trying to process the file (command line, via a web based tool, ...) but I suspect that you are using something like phpMyAdmin's web based interface which is the most common way people interact with mySQL (aside from through their own code) in my experience.

Here you will run into issues with both PHP and the web server it is running within having limits on the size of any single upload. These limits are in place to prevent DoS issues (accidental or otherwise) due to /tmp or other areas becoming full so unless you run you own server you probably won't be able to get the limits pushed up high enough to deal with that large a file. If you do run your own server, see pages like this answer for details of how to make the required changes.

Other than this you have four options:

  1. Split the file into smaller chunks and process them manually. This could be long winded for such a large file.
  2. If you have shell access, upload the large file to the server and use the command-line mysql tools to import it (unfortunately I don't think phpMyAdmin has the feature to process a "local" file like this otherwise you could upload and then still use that).
  3. Write your own simple PHP script (or other language depending on what is on your server) that reads the uploaded file and runs it. For smaller files loading the file into a string and calling multi_query() should do the trick, but you will run into memory limit issues with a 1.5Gb file so you'll need to be more clever than that (parsing the file and submitting individual statements or groups of statements instead of it all in one go).
  4. Find an existing a tool that already does option 3b (reading a file from the web server's filesystem and processes it) for you.