User Tools

Site Tools


backups:backup_and_restore_mysql_databases

This is an old revision of the document!


Backups - Backup and restore mysql databases

To backup (dump) a single mysql database to a file:

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:

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

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:

mysql> source foodb.sql 
 
or 
 
mysql> \. foodb.sql

where foodb.sql is the dumpfile.

backups/backup_and_restore_mysql_databases.1491231433.txt.gz ยท Last modified: 2020/07/15 09:30 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki