MySQL backup and restore commands for database administration

October 25, 2019 Post tags: mysql | database | administration | linux |

If you run your own Linux powered VPS you probably use MySQL for your databases. This article is a small remainder of various backup operations of MySQL databases using mysqldump, mysql and mysqlimport commands in Linux.

How to backup MySQL database?

To take a backup of MySQL database or databases, the database must exist in the database server and you must have access to it. The format of the command would be.¨

mysqldump --user=root --password --single-transaction database > database.sql
How to backup all databases?

If you want to take backup of all databases, then use the following command with option --all-databases.

mysqldump --user=root --password --single-transaction --all-databases > all_databases.sql
How to dackup MySQL database structure only?

If you only want the backup of database structure without data, then use the option --no-data in the command.

mysqldump --user=root --password --single-transaction --no-data database > database_structure.sql
How to backup MySQL database data only?

To backup database Data only without structure, then use the option --no-create-info with the command.

mysqldump --user=root --password --single-transaction --no-create-db --no-create-info database > database_data.sql

How to restore MySQL database?

In the above tutorial we have seen the how to take the backup of databases, structures and data only, now we will see how to restore them using following format.

mysql --user=root --password databse < database.sql

If you want to restore a database that already exist on targeted machine, then you will need to use the mysqlimport command.

mysqlimport --user=root --password databse < database.sql

In the same way you can also restore database tables, structures and data.

Product - ORI PWA

Speed up your business with PWA application. PWA can be your website and mobile application for both Android and iOS.

We have taken special care to include everything you need. Reduce your headaches both during production and regular maintenance.

Our PWA can pull data from anywhere, custom RESTFUL api, Word Press, Magento, Drupal, Contentful, XML, JSON, spreadsheets and more. We can organize, display and process pulled data per your liking.

Do you want a hassle-free, modern and super fast website?

Find out more


ORI provides full business web identity creation service! Contact us