Basic Configuration

Creating A Database

Create new DB user and database.
mysql -u root -p

CREATE USER IF NOT EXISTS '{USER}'@'{DOMAIN}' IDENTIFIED BY '{PASS}';
CREATE DATABASE IF NOT EXISTS {DB};

GRANT ALL PRIVILEGES ON {DB}.* TO '{USER}'@'{DOMAIN}';
FLUSH PRIVILEGES;

Import A Database

Import DB and set appropriate DB permissions.
mysql -u {USER} -p {DATABASE} < database-dump.sql
ALTER DATABASE {DB USER} OWNER TO {DB USER};
GRANT ALL PRIVILEGES ON DATABASE {DB USER} TO {DB USER};

Database Backup

Backup Entire Instance

This will dump all databases, users and permissions. Remember to pull the data from the instance or the data directory.

mysqldump --user=root --password --lock-tables --all-databases > {DATABASES}.sql

Backup A Specific Database

Backup a specific database. Permissions will need to be restored with database.

mysql -u root -p {DATABASE} > {DATABASE}.sql