• 9849-xxx-xxx
  • noreply@example.com
  • Tyagal, Patan, Lalitpur
Import .sql file from terminal [Fast] [Way]

Import .sql file from terminal [Fast] [Way]

Are you trying to import .sql file?
Are you trying to import it from phpmyadmin?
Is your .sql file’s size greater than the limit?

Here I am about to show you how to import .sql file directly from terminal. You need ssh access to import from terminal. But before starting, let me tell you some advantage to import .sql file from terminal over phpmyadmin.


  1. No limit
    • You don’t need to care about import size limit if you choose to import your database from terminal. However, if you use phpmyadmin , based on various server, you will get different limits which will bother you a lot. So, the best idea is to just remember one line of command in terminal and import sql file.
  2. Saves time
    • Yes. Going through terminal, you will save lots of time. Let me explain how by showing you the steps required to take if you select phpmyadmin import approach.
      • First, you will need to download .sql file from your source server to your local machine.
      • Second, you need to upload .sql file to your destination server.
      • Finally, you are in a state to actually import .sql file.
      • Conclusion: You are wasting your time first by downloading the file and later importing the same file.
    • If you choose terminal approach, you don’t need to wait for download at least. You can download it from source server and use mysql command to import directly. This time, you are saving time by not uploading the file. If your .sql file size is less, this doesn’t matter much. But if the size is huge, this really makes lots of difference.

Import command

mysql -u username -p database_name < database_file.sql

# And type password for the username provided above.
# First goto your location where you have saved `database_file.sql` file and hit the command mentioned above.

That’s all. Once you hit that command, you will get datas imported super fast⚡️. I hope this post is helpful to you. Please do share it. That would be highly appreciated. And if you do have any confusion or need help, let me know. I will be happy to help. Use comment section for help or anything ?.


Leave a Reply

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