Restore And Backup MySQL Server Using Command Line On Linux

MySQL is an open-source database server available in today’s world. It’s important to have a backup of your files and application. It helps you to restore the backup of applications and websites etc according to your need. We can restore and backup of MySQL database using mysqldump command line on Linux.

Restore And Backup MySQL Server:

mysqldump is a command-line interface with the help of you can have a backup of your database.

Check Out: Different Ways of Finding Table Size In Mysql Server

Let’s begin

I have created a test database on my database server and changed the database.

create database test;

mysqldump command linux

For backup, The command is

mysqldump –u username –p [database_name] > filename.sql
mysqldump -u root -p test > testdb.sql

Check Out: How To Check Users In Mysql Database Server In Linux

Now backup has been created.

backup created

Command For Restore, The command is  

mysql –u username –p [database_name] < filename.sql

restore mysql dump to new database

The above command is to take only one database if you want all database backup together with you can use this command.

mysqldump –u username –p --all-database > filename.sql

mysql backup

Check Out: MySQL Error “Too Many Connections”

if you need to have a backup in a tar file that reduces the size of the database file, You will have to specify the method in mysqldump command Linux.

mysqldump –u username –p | gzip/bzip2 > filename.sql

mysql backup database

It’s good practice to have a backup in compressed form.

That’s it.  restore mysqldump commnad  linux mysql backup database

Share on:

I'm the founder of Curious Viral. I hope this blog will provide you complete information about Linux Technology & I would like to share my technical knowledge with you which I have learned during this period.

Other Posts You May Like...

Leave a comment