Search results for:
Table of Contents
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).
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
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
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
Restore databases running the following command
mysql -u user -p[user_pass] [database_name] < dumpfile.sql
mysql -u root -pABC123 exampledb < exampledbdump.sql
Written by Michael Brower / September 28, 2017