How to Import Large SQL file in phpMyAdmin?

Highlights

    • If you face issues like file size limits, timeout errors, or memory exhaustion while importing large files to phpmyadmin, you can try these solutions: Compress SQL File, Increase Your Server’s PHP File Size Limit, Use MySQL Command in Terminal.

 

  • Below, you will find the detailed steps to successfully import your large SQL file.

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.


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.


➢ 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.


➢ 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.

Hjalp dette svar dig?

Relaterede artikler

How to Create a Database in MySQL With Command Line?

MySQL is one of the most widely used database management systems, powering everything from small...

How to Install phpMyAdmin with XAMPP?

In the world of web development, having a local server environment and a database is essential...

How Do I Connect MySQL Database Via MySQL Workbench?

Whether you manage a bustling online store’s database or are just working on your personal...