MySql

Backup

In order for the backup to work, you need to provide LOCK TABLES permission.

1
GRANT LOCK TABLES ON `dbname`.* TO 'backupuser@'hostname;

Restore the data from the backup

mysql -u username -p database < mysql_dump.sql

You will be asked for the password interactively.

See user permissions

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
$ mysql -u username -p

mysql> show grants;
+-------------------------------------------------------------------------------------------------------------------------+
| Grants for username@localhost                                                                                   |
+-------------------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'username@'localhost' IDENTIFIED BY PASSWORD '*1DCC9264F13F90CDA7F67C18BE6DF06FCF436498' |
| GRANT ALL PRIVILEGES ON `dbname`.* TO 'username@'localhost' WITH GRANT OPTION                       |
+-------------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)