Need to make a complete dump of all databases in your MySQL-server? Then this command is quite handy;
mysqldump -h -u -p --all-databases | gzip -9 > /location/for/backup/mysqldump.gz
This will prompt for a password — however, if you want to script it, you can of course put this in the command;
mysqldump -h -u -p --all-databases | gzip -9 > /location/for/backup/mysqldump.gz
Also keep in mind that the database(s) will be locked while backing up, to avoid things to be written/changed/deleted while backing up (which would cause inconsistency).