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

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

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

A proud DevriX team member

WordPress Development agency building complete solutions for successful businesses.

DX GitHub Badge
WordPress Core Contributions
  • [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 ...
  • [38892] Twenty Seventeen: Resolves the pin icon having variations This fixes ...

View all 14 tickets on Trac.

Recent Posts
Recent Comments