Backing up and Restoring Databases

Export

# export a single database
--host="host" --user="username" --password --port=3306 "db_name"
# export all databases
mysqldump -u root -p --all-databases > database_backups.sql

Rename

You can use the exported backup file to rename that database. What is the database called and what database to use is defined in the first two lines.

CREATE DATABASE IF NOT EXISTS `database_wp`;
USE `database_wp`;

Import

--host="host" --user="username" --password --port=3306 --database=db_name < "path/to/backup/file.sql"