Backup MySQL database from MySQLDump File Command Line Linux


To backup your MySQL database from mysqldump file, Simply type the MySQL command mysqldump -u [username] –p[password] [database_name] > [dump_file.sql] on the Linux Ubuntu command line and press enter, and it will take database backup and store dump file into your specified location.

How to Take Backup of MySQL database from mysqlDump File in Linux Ubuntu Command Line

Here are some steps to take backup of MySQL database using mysqldump file via terminal on Linux Ubuntu Server:

Step 1: Log in to your MySQL server

To login into the MySQL server, Simply type mysql -u root -p command on the command line or prompt, and press enter:

mysql -u root -p

Step 2: Select the database

After login to MySQL server, you need to select db which you want to backup, for this, you can use use my_database; command on command line:

use my_database;

Replace ‘my_database‘ with the name you want to give your database.

Step 3: Backup a MySQL Database Using mysqldump via Command Line

To backup MySQL database using mysqldump, Just type the mysqldump -u [username] –p[password] [database_name] > [dump_file.sql] on Linux Ubuntu command line, which you can use like this:

mysqldump -u [username] –p[password] [database_name] > [dump_file.sql]


  1. mysqldump: Command-line utility in MySQL used for exporting databases or specific tables.
  2. -u [username]: Specifies the MySQL user for authentication.
  3. –p[password]: Indicates the password for the specified user. There should be no space between -p and the password.
  4. [database_name]: Specifies the name of the MySQL database to be dumped.
  5. > [dump_file.sql]: Redirects the output of the mysqldump command to a file named dump_file.sql. This file will contain the SQL statements necessary to recreate the specified database.

Compress Backup of MySQL Database in Linux Command Line

If the size of MySQL db is more than 3GB, you will need to backup the db by compressing it, you can use mysqldump database_name -u database_username -p | gzip > database_backup_name.sql.gz command on the linux ubuntu command prompt:

mysqldump database_name -u  database_username -p | gzip > database_backup_name.sql.gz

Multiple MySQL Database Backup using mysqldump in Linux Command Line

To backup multiple or all MySQL databases at once, Just type mysqldump mysqldump –databases mydb1 mydb2 > backup.sql on the command line and press enter, this will backup all your MySQL databases in one file:

mysqldump --databases mydb1 mydb2 > backup.sql

Step 4: Verify the restore

Open a terminal and use the cd command to navigate to the directory where the MySQL database backup file is located.

cd /path/to/backup/directory

Use the ls command to list the files in the directory and verify the presence of the MySQL database backup file.


Here is the video guide on how to take backup of mysql database using mysqldump command in linux command prompt:


With the help of the tutorial, you learned how to take backup of MySQL database using mysqldump file via the command line or terminal on linux ubuntu server.

Recommended Tutorials


Jaspreet Singh Ghuman

Jaspreet Singh Ghuman

Passionate Professional Blogger, Freelancer, WordPress Enthusiast, Digital Marketer, Web Developer, Server Operator, Networking Expert. Empowering online presence with diverse skills.

jassweb logo

Jassweb always keeps its services up-to-date with the latest trends in the market, providing its customers all over the world with high-end and easily extensible internet, intranet, and extranet products.


Jassweb, Rai Chak, Punjab, India. 143518
Item added to cart.
0 items - 0.00