Import SQL file using a Linux terminal

If you have bigger database backup and you want to import SQL file into your database it will be easier to use the Terminal. Simply follow these steps:

1) Go to sql file backup directory (e.x. Desktop)

2) In terminal:

metodiew@metodiew:~/Desktop$ mysql -u <database username> -p <user password> <database name>  < <your file>.sql

Note: you can skip <database name> if you have one SQL backup file.

metodiew@metodiew:~/Desktop$ mysql -u <database username> -p <user password>  < <your sql backup file>.sql

Of course you can using phpMyAdmin Import option, but you might have problems if your file is bigger and you don’t have made any changes to your server configuration. Also it will be faster and easier for person who is comfortable with working Linux terminal to type two-line command and to wait for uploading the file. If the file is larger, you can always go for a coffee šŸ™‚

Keep in mind this post it mostly for me, because Iā€™m a lazy person when it comes to remembering commands, so it will be easier for me to find the snipped and to use them in the future šŸ˜€

Stanko Metodiev is a WordPress veteran and the CTO of DevriX. For the past 12 years Stanko has been developing complex SaaS platforms, multisite solutions, migrating various systems to WordPress, managing a team of developers and leading a few key international projects in the company. In the past years, Stanko is the lead organizer of the WordPress Sofia User Group (WPBGUG) and has been a part of the organization of WordCamp Sofia and WordCamp Bulgaria. In his portfolio, you can find free themes and plugins on, and badges of his membership in the WordPress support, polyglots, theme reviews teams. Stanko is a fan of Real Madrid and often watches football games in shisha bars with friends and with his family at home. Also an avid fan of Counter-Strike and an active member of the remote work culture worldwide.

Tagged with: , , , , ,
Posted in Linux, Tips and Tricks

Leave a Reply

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


This site uses Akismet to reduce spam. Learn how your comment data is processed.

A proud DevriX team member

WordPress Development agency building complete solutions for successful businesses.

WordPress Core Contributions
  • [49216] Bundled Themes: Import Twenty Twenty-One, the new default theme for ...
  • [43345] I18N: Remove unused MediaElement.js strings. Props metodiew. See ...
  • [42160] About: Fix grammar typo with pluralization. Props metodiew, ...
  • [42159] About: Fix grammar typo with pluralization. Props metodiew, ...
  • [41339] Widgets: Use `word-wrap: break-word` for available widget ...

View all 15 tickets on Trac.

Recent Posts
Recent Comments