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
# export to a remote server
mysqldump --host servername dbname > dbname.sql
# import database at remote server
mysqldump --host 192.168.1.15 -P 3306 -u dev -pmjQ9Y mydb > mydb.sql
# backup without locking the tables
mysqldump -u username -p --single-transaction --quick --lock-tables=false -h ipaddress myDB > backup.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"