This wiki was updated to MediaWiki 1.37. If you notice any issues, please report them to admin[at]

SDB:MySQL backup

Jump to: navigation, search

Tested on openSUSE

Recommended articles

The easiest way, how to backup your MySQL is to create dump of the database using mysqldump. It will convert your data into text file with sequence of commands that will recreate your database from scratch.

Backing up a MySQL database

To back up a MySQL database using mysqldump, use following command on the server

mysqldump --add-drop-table -h localhost -u <username> -p <database> > database.sql

It will ask you for your password and then create a backup of your database. Do not forget to replace <username> and <database> with your values. If you want to backup everything, you can use:

mysqldump --add-drop-database --add-drop-table -u <username> -p -A > databases.sql

It will backup all databases including "mysql" database, which contains various settings like user accounts.

Restoring a MySQL database

You can restore your database using following command:

mysql -u <username> -p database < database.sql

Simalary, if you want to restore everything, use:

mysql -u <username> -p database < databases.sql

As you may notice, only difference is the name of the input file.