# 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.
- Create an appropriately named database on the target machine
- 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]