I tried Crouse's script from this thread.

Code:
#!/bin/sh 
for i in `mysql -B -e 'show databases'; | tail +2`; do
mysqldump --opt $i | gzip -9 > /var/backups/mysql/$i.`date --iso-8601`.gz
ls -t /var/backups/mysql/$i.* | tail +7 | xargs rm -f
done
But it gives me this error:

Code:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
Do I have to grant privileges to user "root" in mysql or use the root password from the command line?