backups:backup_and_restore_mysql_databases
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
backups:backup_and_restore_mysql_databases [2017/04/03 14:56] – created peter | backups:backup_and_restore_mysql_databases [2019/11/26 20:27] (current) – removed peter | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Backups - Backup and restore mysql databases ====== | ||
- | |||
- | To backup (dump) a single mysql database to a file: | ||
- | |||
- | <code bash> | ||
- | mysqldump -u foo -p foodb > foodb.sql | ||
- | </ | ||
- | |||
- | where: | ||
- | |||
- | * **-u** is for username. | ||
- | * **-p** is for mysqldump to ask for password. | ||
- | * **foodb** is the name of the database. | ||
- | * **foodb.sql** is the file to dump the database. | ||
- | |||
- | |||
- | To backup(dump) all databases to a file: | ||
- | |||
- | <code bash> | ||
- | mysqldump -u foo -p --all-databases > alldb.sql | ||
- | </ | ||
- | |||
- | where: | ||
- | |||
- | * **-u** is for username. | ||
- | * **-p** is for mysqldump to ask for password. | ||
- | * **--all-databases** is to tell mysqldump to dump all databases available. | ||
- | * **alldb.sql** is the dumpfile name. | ||
- | |||
- | |||
- | To restore back mysql database from dumpfile: | ||
- | |||
- | |||
- | 1. From terminal | ||
- | |||
- | <code bash> | ||
- | mysql -u foo -p foodb < foodb.sql | ||
- | </ | ||
- | |||
- | where: | ||
- | |||
- | * **-u** is for username. | ||
- | * **-p** is for mysqldump to ask for password. | ||
- | * **foodb** is the name of the database. | ||
- | * **foodb.sql** is the file to dump the database. | ||
- | |||
- | |||
- | 2. From inside mysql console where you have to access mysql console first: | ||
- | |||
- | <code mysql> | ||
- | mysql> source foodb.sql | ||
- | |||
- | or | ||
- | |||
- | mysql> \. foodb.sql | ||
- | </ | ||
- | |||
- | where foodb.sql is the dumpfile. | ||
backups/backup_and_restore_mysql_databases.1491231397.txt.gz · Last modified: 2020/07/15 09:30 (external edit)