linux:mariadb:mariadb-backup
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| linux:mariadb:mariadb-backup [2021/03/25 14:47] – [Creating the backup] oscar | linux:mariadb:mariadb-backup [Unknown date] (current) – removed - external edit (Unknown date) 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Backup & Restore ====== | ||
| - | ===== Creating the backup ===== | ||
| - | To create the dump, use this command from your shell/ | ||
| - | mysqldump -uusername -ppassword -–default-character-set=utf8 -N database > backup.sql | ||
| - | Where: | ||
| - | * username is your MySQL username. | ||
| - | * password is your MySQL password. | ||
| - | * database is the name of the database you want to backup. | ||
| - | * backup.sql is the full path to the mysql dump file that will contain the backup. | ||
| - | |||
| - | The above command is very efficient and takes very little time to execute. Notice that the character set specified is UTF8. Even if your database is encoded in another character set, I recommend using UTF8 as I found it to work fine with any database without having to make any guesses. | ||
| - | |||
| - | The Nextcloud database is using 4-byte character encoding for emoji. Backup and restore should use: **--default-character-set=utf8mb4** instead! | ||
| - | |||
| - | ===== Restoring the database from your backup ===== | ||
| - | Restoring a database from a backup file is pretty easy. First, empty the database to avoid error messages, then run this command: | ||
| - | mysql -uusername -ppassword -–default-character-set=utf8 database < backup.sql | ||
| - | |||
| - | Where: | ||
| - | username is your MySQL username. | ||
| - | password is your MySQL password. | ||
| - | database is the name of the database you want to restore. | ||
| - | backup.sql is the full path to the mysql dump file that you want to restore from. | ||
| - | You can also use the above command to copy your database from one server to another. This command is very efficient as well and executes in a very short time. | ||
linux/mariadb/mariadb-backup.1616683628.txt.gz · Last modified: (external edit)
