Restore & Backup Mysql Database using mysqldump Command
You have to use command prompt[Windows users] or kernel[Linux users,MacOS] to backup databases.
Backup Mysql Database
- Backup a single database
mysqldump -u root -p[root_mysql_password] [database_name] > [path_to_save_with_sql_extension]
ex:
mysqldump -u root -p123 test > D:/backups/test_backup.sql
- Backup Multiple databases
mysqldump -u root -p[root_mysql_password] --databases [database_name] [database_name] .. > [path_to_save_with_sql_extension]
ex:
suppose we have two databases called test and tutorial
mysqldump -u root -p123 --databases test tutorial > D:/backups/test_tutorial.sql
- Backup all the databases
mysqldump -u root -p[root_mysql_password] -all-databases > [path_to_save_with_sql_extension]
- Backup a specific table
Suppose we have a demo table in test database.
mysqldump -u root -p123 test demo \ > D:/backups/demotables.sql
Restore Mysql Database
To restore mysql database use following command.
mysql -u root -p[root_mysql_password] [database_name] < D:/backups/test.sql
No comments:
Post a Comment