Search The Hostwinds Guides Knowledge Base

Backup And Restore MySQL Databases Using mysqldump

Share This Article [TheChamp-Sharing]

mysqldump lets you quickly and efficiently take a backup of a single database, multiple databases or even all of the databases on your server. This requires shell access to the server you wish to perform the commands on and the mysql login credentials for your user(s).

SSH access is not allowed on our shared or business shared services.  For more information on how to SSH into your server, please review:  Connecting To Your Server Via SSH

Backing Up A Single Database

To back-up a single database, log in via SSH and run the following commands.


mysqldump -u user -p[user_pass] [database_name] > dumpfile.sql


mysqldump -u root -pABC123 exampledb > exampledbdump.sql

The filepath for your database (.sql) backup will be your current working directory. You may use an absolute path as well, such as /root/exampledbdump.sql

Backing Up Multiple Databases

If you wish to backup two or more databases, you’ll need to specify –databases followed by the names of the databases you want to backup. Remember that the database user must have privileges to access the database that is being backed up.


mysqldump -u user -p[user_pass] –databases [database_name] [database_name] [database_name] > dumpfile.sql


mysqldump -u root -pABC123 –databases exampledb sampledb testdb > exampledb_sampledblsql_testdb.sql

Backing Up All Databases

Run the following command to back-up all current databases


mysqldump -u user -p[user_pass] –all-databases > all-dbs.sql


mysqldump -u root -pABC123 –all-databases > all-dbs.sql

Restoring Database(s)

Restore databases running the following command


mysql -u user -p[user_pass] [database_name] < dumpfile.sql


mysql -u root -pABC123 exampledb < exampledbdump.sql

Related Articles