How can a large SQL file be imported into phpMyAdmin?

When importing large SQL files into phpMyAdmin, you can often result in timeouts or server errors.

Don’t worry!

With the right approach and some optimizations, it is possible to import large SQL files into phpMyAdmin successfully.

In this article, we will discuss the solutions with which you can easily import large SQL files in phpMyadmin.


Also Read: How to Fix the 504 Bad Gateway Timeout Error?


Solutions to Import Large SQL file in phpMyAdmin

➢ Solution-1: Compress SQL File

If you have SQL files that are not much larger in size, you can use this solution to import the file in phpMyAdmin quickly.

You just need to compress the .sql file using gzip or zip. You can also use any other compression method as well. With the help of this, you can achieve a major size reduction.


Also Read: How to Download SQL Database From cPanel?


➢ Solution-2: Increase Your Server’s PHP File Size Limit

If the solution mentioned above doesn’t work for you. Increasing your server’s PHP file size limit is another good solution that you can apply to solve this problem.

To do this, you simply need to follow the following:

➔ You have to Open the ‘php.ini’ file on your server.

➔ In that, you just need to update the given lines below.

max_execution_time = 1024    // 30 minutes

max_input_time = 1024        // 30 minutes

memory_limit = 2048M         // 2 GB

upload_max_filesize = 2048M  // 2 GB

post_max_size = 2048M        // 2 GB

➔ Once you update it, just save the file.

After that, restart your web server to apply the changes.


Also Read: How to Increase Max Upload Size in cPanel?


➢ Solution-3: Use MySQL Command in Terminal

Another solution for solving this problem is to consider using the command line in your terminal to import the SQL file.

To do this, you simply need to follow the following:

➔ First, open a terminal and use the following command below when your database file is in any other directory.

mysql -u username -p new_database < /path/old_database.sql

➔ Use the command below if your database file is in the public_html directory.

mysql -u username -p new_database < old_database.sql

In this case: 

★ username: Your username of MYSQL.

★ new_database – A file name in which you want to import your old database file.

★ /path/old_database.sql – Full path to your .sql file or  old_database.sql file name

When prompted, provide your MySQL credentials and complete the import process.

Conclusion

All of these provided solutions are the best for resolving the issue. We hope that they will be helpful for you in mitigating the problem.

Loading

Leave a Reply

Your email address will not be published. Required fields are marked *

[ajax_load_more]