For a new clean install of my mac I had to backup all mysql databases which is pretty simple when you know how to. Just run:

$ mysqldump -u username -p --all-databases > mysql-backup.sql

to backup everything at once and the following to restore it

$ mysql -u username -p < mysql-backup.sql