see mysql manual (www.mysql.com) for more details, but to back up a database use at the shell command line:
$ mysqldump -ppassword [database_name] >/root/to/file_name/to/dump/to
this will dump the whole database structure and data.
To restore:
add to the start of the dumped file:
DROP DATABASE DATABASE_NAME;
CREATE DATABASE DATABASE_NAME;
USE DATABASE_NAME;
and at the end of the file add a GRANT statement e.g.
GRANT INSERT,UPDATE,DELETE,SELECT
ON DATABASE_NAME.*
TO username@localhost
IDENTIFIED BY 'pword';
save file, then go back to the command line:
$ mysql -ppassword </root/to/edited/file
This should restore the database to the state at which you dumped it.
There are other ways, too - check out the manual.