How to backup and restore MySQL Database

How to backup and restore MySQL Database
  • Backup MySQL Databaase Syntax:
  • mysqldump -u root -h localhost -p [database name] > [script file name].sql
  • after entering this command, MySQL will ask for root password. Simply supply password and press enter.
  • To Restore MySQL Database to your newly created database:
  • Make sure that the name of your new database is the same with the name of your old database.
  • mysql -u root -h localhost -p [dataabase name] < [script file name].sql
  • after entering this command, MySQL will ask for root password. Simply supply password and press enter.

No comments: