Category: Linux Terminal

Added: 15th of December 2015

Updated On: 7th of November 2020

Viewed: 2548 times

Import - Export MySQL / MariaDB database using the terminal in Ubuntu Linux

This article was rechecked and updated on 07/11/20

To Export your database using the terminal, in Ubuntu enter the following command:-

mysqldump -u {database_username} -p {database_name} > mysqlbackup.sql


You will be prompted for your MySQL password. Your database will then be downloaded.

To Import your database using the terminal in Ubuntu enter the following command:-
mysql -u {database_username} -p {database_name} < mysqlbackup.sql


You will be prompted for your MySQL password. Your database will then be imported.

Other ways to import and export MySQL:-
There are other ways to Import and Export your database using PHPMyAdmin.
This is fine for small imports and exports but most webhosts impose a 2MB limit on imports.

Using PHPMyAdmin on a live busy site, may also lock all the tables whilst importing or exporting the databases. It also takes longer to import and export using this method.

PHPMyAdmin's strengths are it's ease of use when creating new databases, tables and fields. This can be done directly through your webbrowser, without the need to use the terminal.

Other Tips & Tutorials

Linux Terminal

Kill multiple processes using the pkill command in Linux

Posted: 5th of January 2021

Views: 721

Linux Terminal

Display free memory using the terminal in Linux

Posted: 17th of December 2020

Views: 675

Linux Terminal

Using mlocate to find files by name, extension using the terminal in Linux

Posted: 27th of November 2020

Views: 595

Linux Terminal

Capture screenshots of websites using cutycapt in different formats using the terminal in Ubuntu and Ubuntu based distributions

Posted: 15th of November 2020

Views: 832

Linux Terminal

Display a calendar in the terminal

Posted: 6th of November 2020

Views: 748

Linux Terminal

Create a simple cronjob in Linux

Posted: 20th of October 2020

Views: 858

Linux Terminal

Create a new folder and file using the mkdir and touch commands using the terminal in Linux

Posted: 16th of August 2020

Views: 805

Linux Terminal

Convert a PDF document to text or html using pdftotext, pdftohtml in Linux using the terminal

Posted: 3rd of August 2020

Views: 1218

Linux Terminal

List files in a directory using the ls command

Posted: 22nd of July 2020

Views: 841

Linux Terminal

How to access HP Linux Imaging and Printing System set up on Ubuntu using the terminal

Posted: 13th of November 2019

Views: 1488