Up to $140 off-Lowest  Prices of 2024(Nov.21-Dec.2)

My Computer Tips

Home | About | Categories | All Tips & Tutorials

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

ID: 47

Category: Linux Terminal

Added: 15th of December 2015

Updated On: Tutorial updated and rechecked on 7th of November 2020

Views: 3,833

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.