Tag Archives: mysql

Backup and Restore MySQL via MySQLdump

To backup:

# mysqldump -u root -p[password] database_name > database_name_backup.sql

[password] should be placed immediately after -p. For example: -pmypassword. database_name_backup.sql would be created in the root directory.

To restore:

  1. Create an appropriately named database on the target machine
  2. Load the file using the mysql command:
    # mysql -u [uname] -p[pass] [db_to_restore] < [backupfile.sql]

To restore a database that already exists, use mysqlimport command:
mysqlimport -u [uname] -p[pass] [dbname] [backupfile.sql]

Source: How to Back Up and Restore a MySQL Database