Backup and Restore Mysql using command line


SSH into your Ubuntu MySql server and backup the headstation database to headstation_20141207.sql with:

mysqldump -u root -p headstation  > headstation_20141207.sql

Restore with:

mysql -u root -p headstation < headstation_20141207.sql

Log into mysql and create new db and apply root permissions before you can restore:

mysql -u root -p

Create database headstation:

grant all privileges on *.* to 'root'@'%';

Create a new user and grant permissions:

CREATE USER 'newuser'@'%' IDENTIFIED BY 'test';
grant all privileges on *.* to 'newuser'@'%';