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 technical lead and a Project Manager at DevriX. Here is also a WordPress Core contributor, themes and plugins author and occasional speaker.

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

Leave a Reply

Your email address will not be published.


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